Skip to content

Commit 6cc5a3d

Browse files
committed
Forward max and min to max_by and min_by respectively
1 parent 1819250 commit 6cc5a3d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/libcore/iter/traits/iterator.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2008,8 +2008,7 @@ pub trait Iterator {
20082008
#[stable(feature = "rust1", since = "1.0.0")]
20092009
fn max(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
20102010
{
2011-
// switch to y even if it is only equal, to preserve stability.
2012-
select_fold1(self, |x, y| x <= y)
2011+
self.max_by(Ord::cmp)
20132012
}
20142013

20152014
/// Returns the minimum element of an iterator.
@@ -2034,8 +2033,7 @@ pub trait Iterator {
20342033
#[stable(feature = "rust1", since = "1.0.0")]
20352034
fn min(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
20362035
{
2037-
// only switch to y if it is strictly smaller, to preserve stability.
2038-
select_fold1(self, |x, y| x > y)
2036+
self.min_by(Ord::cmp)
20392037
}
20402038

20412039
/// Returns the element that gives the maximum value from the

0 commit comments

Comments
 (0)