提交 6cc5a3d9 编写于 作者: T Tim Vermeulen

Forward `max` and `min` to `max_by` and `min_by` respectively

上级 18192505
......@@ -2008,8 +2008,7 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
#[stable(feature = "rust1", since = "1.0.0")]
fn max(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
{
// switch to y even if it is only equal, to preserve stability.
select_fold1(self, |x, y| x <= y)
self.max_by(Ord::cmp)
}
/// Returns the minimum element of an iterator.
......@@ -2034,8 +2033,7 @@ fn max(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
#[stable(feature = "rust1", since = "1.0.0")]
fn min(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
{
// only switch to y if it is strictly smaller, to preserve stability.
select_fold1(self, |x, y| x > y)
self.min_by(Ord::cmp)
}
/// Returns the element that gives the maximum value from the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册