Skip to content

Commit 7ef46e0

Browse files
committed
doc: the prevailing convention is to use assert_eq! when 2 values are compared
1 parent a39d4fc commit 7ef46e0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/libcore/iter.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub trait Iterator {
137137
///
138138
/// ```
139139
/// let a = [1, 2, 3, 4, 5];
140-
/// assert!(a.iter().last().unwrap() == &5);
140+
/// assert_eq!(a.iter().last().unwrap(), &5);
141141
/// ```
142142
#[inline]
143143
#[stable(feature = "rust1", since = "1.0.0")]
@@ -155,8 +155,8 @@ pub trait Iterator {
155155
/// ```
156156
/// let a = [1, 2, 3, 4, 5];
157157
/// let mut it = a.iter();
158-
/// assert!(it.nth(2).unwrap() == &3);
159-
/// assert!(it.nth(2) == None);
158+
/// assert_eq!(it.nth(2).unwrap(), &3);
159+
/// assert_eq!(it.nth(2), None);
160160
/// ```
161161
#[inline]
162162
#[stable(feature = "rust1", since = "1.0.0")]
@@ -545,8 +545,8 @@ pub trait Iterator {
545545
/// let mut it = 0..10;
546546
/// // sum the first five values
547547
/// let partial_sum = it.by_ref().take(5).fold(0, |a, b| a + b);
548-
/// assert!(partial_sum == 10);
549-
/// assert!(it.next() == Some(5));
548+
/// assert_eq!(partial_sum, 10);
549+
/// assert_eq!(it.next(), Some(5));
550550
/// ```
551551
#[stable(feature = "rust1", since = "1.0.0")]
552552
fn by_ref(&mut self) -> &mut Self where Self: Sized { self }
@@ -608,7 +608,7 @@ pub trait Iterator {
608608
///
609609
/// ```
610610
/// let a = [1, 2, 3, 4, 5];
611-
/// assert!(a.iter().fold(0, |acc, &item| acc + item) == 15);
611+
/// assert_eq!(a.iter().fold(0, |acc, &item| acc + item), 15);
612612
/// ```
613613
#[inline]
614614
#[stable(feature = "rust1", since = "1.0.0")]
@@ -773,7 +773,7 @@ pub trait Iterator {
773773
///
774774
/// ```
775775
/// let a = [1, 2, 3, 4, 5];
776-
/// assert!(a.iter().max().unwrap() == &5);
776+
/// assert_eq!(a.iter().max().unwrap(), &5);
777777
/// ```
778778
#[inline]
779779
#[stable(feature = "rust1", since = "1.0.0")]
@@ -796,7 +796,7 @@ pub trait Iterator {
796796
///
797797
/// ```
798798
/// let a = [1, 2, 3, 4, 5];
799-
/// assert!(a.iter().min().unwrap() == &1);
799+
/// assert_eq!(a.iter().min().unwrap(), &1);
800800
/// ```
801801
#[inline]
802802
#[stable(feature = "rust1", since = "1.0.0")]
@@ -834,13 +834,13 @@ pub trait Iterator {
834834
/// assert_eq!(a.iter().min_max(), NoElements);
835835
///
836836
/// let a = [1];
837-
/// assert!(a.iter().min_max() == OneElement(&1));
837+
/// assert_eq!(a.iter().min_max(), OneElement(&1));
838838
///
839839
/// let a = [1, 2, 3, 4, 5];
840-
/// assert!(a.iter().min_max() == MinMax(&1, &5));
840+
/// assert_eq!(a.iter().min_max(), MinMax(&1, &5));
841841
///
842842
/// let a = [1, 1, 1, 1];
843-
/// assert!(a.iter().min_max() == MinMax(&1, &1));
843+
/// assert_eq!(a.iter().min_max(), MinMax(&1, &1));
844844
/// ```
845845
#[unstable(feature = "core", reason = "return type may change")]
846846
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord
@@ -1058,7 +1058,7 @@ pub trait Iterator {
10581058
///
10591059
/// let a = [1, 2, 3, 4, 5];
10601060
/// let mut it = a.iter().cloned();
1061-
/// assert!(it.sum::<i32>() == 15);
1061+
/// assert_eq!(it.sum::<i32>(), 15);
10621062
/// ```
10631063
#[unstable(feature="core")]
10641064
fn sum<S=<Self as Iterator>::Item>(self) -> S where
@@ -1078,9 +1078,9 @@ pub trait Iterator {
10781078
/// fn factorial(n: u32) -> u32 {
10791079
/// (1..).take_while(|&i| i <= n).product()
10801080
/// }
1081-
/// assert!(factorial(0) == 1);
1082-
/// assert!(factorial(1) == 1);
1083-
/// assert!(factorial(5) == 120);
1081+
/// assert_eq!(factorial(0), 1);
1082+
/// assert_eq!(factorial(1), 1);
1083+
/// assert_eq!(factorial(5), 120);
10841084
/// ```
10851085
#[unstable(feature="core")]
10861086
fn product<P=<Self as Iterator>::Item>(self) -> P where

0 commit comments

Comments
 (0)