@@ -321,14 +321,11 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> {
321321/// ```
322322/// use std::cmp::Ordering;
323323///
324- /// let result = 1.cmp(&2);
325- /// assert_eq!(Ordering::Less, result);
324+ /// assert_eq!(1.cmp(&2), Ordering::Less);
326325///
327- /// let result = 1.cmp(&1);
328- /// assert_eq!(Ordering::Equal, result);
326+ /// assert_eq!(1.cmp(&1), Ordering::Equal);
329327///
330- /// let result = 2.cmp(&1);
331- /// assert_eq!(Ordering::Greater, result);
328+ /// assert_eq!(2.cmp(&1), Ordering::Greater);
332329/// ```
333330#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug , Hash ) ]
334331#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -784,8 +781,8 @@ pub trait Ord: Eq + PartialOrd<Self> {
784781 /// # Examples
785782 ///
786783 /// ```
787- /// assert_eq!(2, 1.max(2));
788- /// assert_eq!(2, 2 .max(2));
784+ /// assert_eq!(1.max(2), 2 );
785+ /// assert_eq!(2.max(2), 2 );
789786 /// ```
790787 #[ stable( feature = "ord_max_min" , since = "1.21.0" ) ]
791788 #[ inline]
@@ -804,8 +801,8 @@ pub trait Ord: Eq + PartialOrd<Self> {
804801 /// # Examples
805802 ///
806803 /// ```
807- /// assert_eq!(1, 1 .min(2));
808- /// assert_eq!(2, 2 .min(2));
804+ /// assert_eq!(1.min(2), 1 );
805+ /// assert_eq!(2.min(2), 2 );
809806 /// ```
810807 #[ stable( feature = "ord_max_min" , since = "1.21.0" ) ]
811808 #[ inline]
@@ -829,9 +826,9 @@ pub trait Ord: Eq + PartialOrd<Self> {
829826 /// # Examples
830827 ///
831828 /// ```
832- /// assert !((-3).clamp(-2, 1) == -2);
833- /// assert !(0.clamp(-2, 1) == 0);
834- /// assert !(2.clamp(-2, 1) == 1);
829+ /// assert_eq !((-3).clamp(-2, 1), -2);
830+ /// assert_eq !(0.clamp(-2, 1), 0);
831+ /// assert_eq !(2.clamp(-2, 1), 1);
835832 /// ```
836833 #[ must_use]
837834 #[ stable( feature = "clamp" , since = "1.50.0" ) ]
@@ -1060,11 +1057,9 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10601057 /// # Examples
10611058 ///
10621059 /// ```
1063- /// let result = 1.0 < 2.0;
1064- /// assert_eq!(result, true);
1065- ///
1066- /// let result = 2.0 < 1.0;
1067- /// assert_eq!(result, false);
1060+ /// assert_eq!(1.0 < 1.0, false);
1061+ /// assert_eq!(1.0 < 2.0, true);
1062+ /// assert_eq!(2.0 < 1.0, false);
10681063 /// ```
10691064 #[ inline]
10701065 #[ must_use]
@@ -1079,11 +1074,9 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10791074 /// # Examples
10801075 ///
10811076 /// ```
1082- /// let result = 1.0 <= 2.0;
1083- /// assert_eq!(result, true);
1084- ///
1085- /// let result = 2.0 <= 2.0;
1086- /// assert_eq!(result, true);
1077+ /// assert_eq!(1.0 <= 1.0, true);
1078+ /// assert_eq!(1.0 <= 2.0, true);
1079+ /// assert_eq!(2.0 <= 1.0, false);
10871080 /// ```
10881081 #[ inline]
10891082 #[ must_use]
@@ -1097,11 +1090,9 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10971090 /// # Examples
10981091 ///
10991092 /// ```
1100- /// let result = 1.0 > 2.0;
1101- /// assert_eq!(result, false);
1102- ///
1103- /// let result = 2.0 > 2.0;
1104- /// assert_eq!(result, false);
1093+ /// assert_eq!(1.0 > 1.0, false);
1094+ /// assert_eq!(1.0 > 2.0, false);
1095+ /// assert_eq!(2.0 > 1.0, true);
11051096 /// ```
11061097 #[ inline]
11071098 #[ must_use]
@@ -1116,11 +1107,9 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
11161107 /// # Examples
11171108 ///
11181109 /// ```
1119- /// let result = 2.0 >= 1.0;
1120- /// assert_eq!(result, true);
1121- ///
1122- /// let result = 2.0 >= 2.0;
1123- /// assert_eq!(result, true);
1110+ /// assert_eq!(1.0 >= 1.0, true);
1111+ /// assert_eq!(1.0 >= 2.0, false);
1112+ /// assert_eq!(2.0 >= 1.0, true);
11241113 /// ```
11251114 #[ inline]
11261115 #[ must_use]
@@ -1150,8 +1139,8 @@ pub macro PartialOrd($item:item) {
11501139/// ```
11511140/// use std::cmp;
11521141///
1153- /// assert_eq!(1, cmp::min(1, 2));
1154- /// assert_eq!(2, cmp::min(2, 2));
1142+ /// assert_eq!(cmp::min(1, 2), 1 );
1143+ /// assert_eq!(cmp::min(2, 2), 2 );
11551144/// ```
11561145#[ inline]
11571146#[ must_use]
@@ -1170,8 +1159,11 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T {
11701159/// ```
11711160/// use std::cmp;
11721161///
1173- /// assert_eq!(cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 1);
1174- /// assert_eq!(cmp::min_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
1162+ /// let result = cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs()));
1163+ /// assert_eq!(result, 1);
1164+ ///
1165+ /// let result = cmp::min_by(-2, 3, |x: &i32, y: &i32| x.abs().cmp(&y.abs()));
1166+ /// assert_eq!(result, -2);
11751167/// ```
11761168#[ inline]
11771169#[ must_use]
@@ -1192,8 +1184,11 @@ pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
11921184/// ```
11931185/// use std::cmp;
11941186///
1195- /// assert_eq!(cmp::min_by_key(-2, 1, |x: &i32| x.abs()), 1);
1196- /// assert_eq!(cmp::min_by_key(-2, 2, |x: &i32| x.abs()), -2);
1187+ /// let result = cmp::min_by_key(-2, 1, |x: &i32| x.abs());
1188+ /// assert_eq!(result, 1);
1189+ ///
1190+ /// let result = cmp::min_by_key(-2, 2, |x: &i32| x.abs());
1191+ /// assert_eq!(result, -2);
11971192/// ```
11981193#[ inline]
11991194#[ must_use]
@@ -1213,8 +1208,8 @@ pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
12131208/// ```
12141209/// use std::cmp;
12151210///
1216- /// assert_eq!(2, cmp::max(1, 2));
1217- /// assert_eq!(2, cmp::max(2, 2));
1211+ /// assert_eq!(cmp::max(1, 2), 2 );
1212+ /// assert_eq!(cmp::max(2, 2), 2 );
12181213/// ```
12191214#[ inline]
12201215#[ must_use]
@@ -1233,8 +1228,11 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
12331228/// ```
12341229/// use std::cmp;
12351230///
1236- /// assert_eq!(cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), -2);
1237- /// assert_eq!(cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())), 2);
1231+ /// let result = cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs()));
1232+ /// assert_eq!(result, -2);
1233+ ///
1234+ /// let result = cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())) ;
1235+ /// assert_eq!(result, 2);
12381236/// ```
12391237#[ inline]
12401238#[ must_use]
@@ -1255,8 +1253,11 @@ pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
12551253/// ```
12561254/// use std::cmp;
12571255///
1258- /// assert_eq!(cmp::max_by_key(-2, 1, |x: &i32| x.abs()), -2);
1259- /// assert_eq!(cmp::max_by_key(-2, 2, |x: &i32| x.abs()), 2);
1256+ /// let result = cmp::max_by_key(-2, 1, |x: &i32| x.abs());
1257+ /// assert_eq!(result, -2);
1258+ ///
1259+ /// let result = cmp::max_by_key(-2, 2, |x: &i32| x.abs());
1260+ /// assert_eq!(result, 2);
12601261/// ```
12611262#[ inline]
12621263#[ must_use]
0 commit comments