提交 65504205 编写于 作者: M Manish Goregaokar

Rollup merge of #25194 - tshepang:assert-convention, r=steveklabnik

… compared
......@@ -137,7 +137,7 @@ fn count(self) -> usize where Self: Sized {
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert!(a.iter().last().unwrap() == &5);
/// assert_eq!(a.iter().last().unwrap(), &5);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
......@@ -155,8 +155,8 @@ fn last(self) -> Option<Self::Item> where Self: Sized {
/// ```
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter();
/// assert!(it.nth(2).unwrap() == &3);
/// assert!(it.nth(2) == None);
/// assert_eq!(it.nth(2).unwrap(), &3);
/// assert_eq!(it.nth(2), None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
......@@ -545,8 +545,8 @@ fn inspect<F>(self, f: F) -> Inspect<Self, F> where
/// let mut it = 0..10;
/// // sum the first five values
/// let partial_sum = it.by_ref().take(5).fold(0, |a, b| a + b);
/// assert!(partial_sum == 10);
/// assert!(it.next() == Some(5));
/// assert_eq!(partial_sum, 10);
/// assert_eq!(it.next(), Some(5));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
......@@ -608,7 +608,7 @@ fn partition<B, F>(self, mut f: F) -> (B, B) where
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert!(a.iter().fold(0, |acc, &item| acc + item) == 15);
/// assert_eq!(a.iter().fold(0, |acc, &item| acc + item), 15);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
......@@ -773,7 +773,7 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert!(a.iter().max().unwrap() == &5);
/// assert_eq!(a.iter().max().unwrap(), &5);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
......@@ -796,7 +796,7 @@ fn max(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
///
/// ```
/// let a = [1, 2, 3, 4, 5];
/// assert!(a.iter().min().unwrap() == &1);
/// assert_eq!(a.iter().min().unwrap(), &1);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
......@@ -834,13 +834,13 @@ fn min(self) -> Option<Self::Item> where Self: Sized, Self::Item: Ord
/// assert_eq!(a.iter().min_max(), NoElements);
///
/// let a = [1];
/// assert!(a.iter().min_max() == OneElement(&1));
/// assert_eq!(a.iter().min_max(), OneElement(&1));
///
/// let a = [1, 2, 3, 4, 5];
/// assert!(a.iter().min_max() == MinMax(&1, &5));
/// assert_eq!(a.iter().min_max(), MinMax(&1, &5));
///
/// let a = [1, 1, 1, 1];
/// assert!(a.iter().min_max() == MinMax(&1, &1));
/// assert_eq!(a.iter().min_max(), MinMax(&1, &1));
/// ```
#[unstable(feature = "core", reason = "return type may change")]
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord
......@@ -1058,7 +1058,7 @@ fn reverse_in_place<'a, T: 'a>(&mut self) where
///
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().cloned();
/// assert!(it.sum::<i32>() == 15);
/// assert_eq!(it.sum::<i32>(), 15);
/// ```
#[unstable(feature="core")]
fn sum<S=<Self as Iterator>::Item>(self) -> S where
......@@ -1078,9 +1078,9 @@ fn sum<S=<Self as Iterator>::Item>(self) -> S where
/// fn factorial(n: u32) -> u32 {
/// (1..).take_while(|&i| i <= n).product()
/// }
/// assert!(factorial(0) == 1);
/// assert!(factorial(1) == 1);
/// assert!(factorial(5) == 120);
/// assert_eq!(factorial(0), 1);
/// assert_eq!(factorial(1), 1);
/// assert_eq!(factorial(5), 120);
/// ```
#[unstable(feature="core")]
fn product<P=<Self as Iterator>::Item>(self) -> P where
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册