@@ -124,7 +124,7 @@ pub trait Iterator {
124124 ///
125125 /// ```
126126 /// let a = [1, 2, 3, 4, 5];
127- /// assert !(a.iter().last().unwrap() == &5 );
127+ /// assert_eq !(a.iter().last(), Some(&5) );
128128 /// ```
129129 #[ inline]
130130 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -142,8 +142,8 @@ pub trait Iterator {
142142 /// ```
143143 /// let a = [1, 2, 3, 4, 5];
144144 /// let mut it = a.iter();
145- /// assert !(it.nth(2).unwrap() == &3 );
146- /// assert !(it.nth(2) == None);
145+ /// assert_eq !(it.nth(2), Some(&3) );
146+ /// assert_eq !(it.nth(2), None);
147147 /// ```
148148 #[ inline]
149149 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -165,8 +165,8 @@ pub trait Iterator {
165165 /// let a = [0];
166166 /// let b = [1];
167167 /// let mut it = a.iter().chain(b.iter());
168- /// assert_eq!(it.next().unwrap(), &0 );
169- /// assert_eq!(it.next().unwrap(), &1 );
168+ /// assert_eq!(it.next(), Some(&0) );
169+ /// assert_eq!(it.next(), Some(&1) );
170170 /// assert!(it.next().is_none());
171171 /// ```
172172 #[ inline]
@@ -188,7 +188,7 @@ pub trait Iterator {
188188 /// let a = [0];
189189 /// let b = [1];
190190 /// let mut it = a.iter().zip(b.iter());
191- /// assert_eq!(it.next().unwrap(), ( &0, &1));
191+ /// assert_eq!(it.next(), Some(( &0, &1) ));
192192 /// assert!(it.next().is_none());
193193 /// ```
194194 ///
@@ -221,8 +221,8 @@ pub trait Iterator {
221221 /// ```
222222 /// let a = [1, 2];
223223 /// let mut it = a.iter().map(|&x| 2 * x);
224- /// assert_eq!(it.next().unwrap(), 2 );
225- /// assert_eq!(it.next().unwrap(), 4 );
224+ /// assert_eq!(it.next(), Some(2) );
225+ /// assert_eq!(it.next(), Some(4) );
226226 /// assert!(it.next().is_none());
227227 /// ```
228228 #[ inline]
@@ -242,7 +242,7 @@ pub trait Iterator {
242242 /// ```
243243 /// let a = [1, 2];
244244 /// let mut it = a.iter().filter(|&x| *x > 1);
245- /// assert_eq!(it.next().unwrap(), &2 );
245+ /// assert_eq!(it.next(), Some(&2) );
246246 /// assert!(it.next().is_none());
247247 /// ```
248248 #[ inline]
@@ -262,7 +262,7 @@ pub trait Iterator {
262262 /// ```
263263 /// let a = [1, 2];
264264 /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None});
265- /// assert_eq!(it.next().unwrap(), 4 );
265+ /// assert_eq!(it.next(), Some(4) );
266266 /// assert!(it.next().is_none());
267267 /// ```
268268 #[ inline]
@@ -286,8 +286,8 @@ pub trait Iterator {
286286 /// ```
287287 /// let a = [100, 200];
288288 /// let mut it = a.iter().enumerate();
289- /// assert_eq!(it.next().unwrap(), ( 0, &100));
290- /// assert_eq!(it.next().unwrap(), ( 1, &200));
289+ /// assert_eq!(it.next(), Some(( 0, &100) ));
290+ /// assert_eq!(it.next(), Some(( 1, &200) ));
291291 /// assert!(it.next().is_none());
292292 /// ```
293293 #[ inline]
@@ -329,9 +329,9 @@ pub trait Iterator {
329329 /// ```
330330 /// let a = [1, 2, 3, 4, 5];
331331 /// let mut it = a.iter().skip_while(|&a| *a < 3);
332- /// assert_eq!(it.next().unwrap(), &3 );
333- /// assert_eq!(it.next().unwrap(), &4 );
334- /// assert_eq!(it.next().unwrap(), &5 );
332+ /// assert_eq!(it.next(), Some(&3) );
333+ /// assert_eq!(it.next(), Some(&4) );
334+ /// assert_eq!(it.next(), Some(&5) );
335335 /// assert!(it.next().is_none());
336336 /// ```
337337 #[ inline]
@@ -351,8 +351,8 @@ pub trait Iterator {
351351 /// ```
352352 /// let a = [1, 2, 3, 4, 5];
353353 /// let mut it = a.iter().take_while(|&a| *a < 3);
354- /// assert_eq!(it.next().unwrap(), &1 );
355- /// assert_eq!(it.next().unwrap(), &2 );
354+ /// assert_eq!(it.next(), Some(&1) );
355+ /// assert_eq!(it.next(), Some(&2) );
356356 /// assert!(it.next().is_none());
357357 /// ```
358358 #[ inline]
@@ -371,8 +371,8 @@ pub trait Iterator {
371371 /// ```
372372 /// let a = [1, 2, 3, 4, 5];
373373 /// let mut it = a.iter().skip(3);
374- /// assert_eq!(it.next().unwrap(), &4 );
375- /// assert_eq!(it.next().unwrap(), &5 );
374+ /// assert_eq!(it.next(), Some(&4) );
375+ /// assert_eq!(it.next(), Some(&5) );
376376 /// assert!(it.next().is_none());
377377 /// ```
378378 #[ inline]
@@ -389,9 +389,9 @@ pub trait Iterator {
389389 /// ```
390390 /// let a = [1, 2, 3, 4, 5];
391391 /// let mut it = a.iter().take(3);
392- /// assert_eq!(it.next().unwrap(), &1 );
393- /// assert_eq!(it.next().unwrap(), &2 );
394- /// assert_eq!(it.next().unwrap(), &3 );
392+ /// assert_eq!(it.next(), Some(&1) );
393+ /// assert_eq!(it.next(), Some(&2) );
394+ /// assert_eq!(it.next(), Some(&3) );
395395 /// assert!(it.next().is_none());
396396 /// ```
397397 #[ inline]
@@ -413,11 +413,11 @@ pub trait Iterator {
413413 /// *fac = *fac * x;
414414 /// Some(*fac)
415415 /// });
416- /// assert_eq!(it.next().unwrap(), 1 );
417- /// assert_eq!(it.next().unwrap(), 2 );
418- /// assert_eq!(it.next().unwrap(), 6 );
419- /// assert_eq!(it.next().unwrap(), 24 );
420- /// assert_eq!(it.next().unwrap(), 120);
416+ /// assert_eq!(it.next(), Some(1) );
417+ /// assert_eq!(it.next(), Some(2) );
418+ /// assert_eq!(it.next(), Some(6) );
419+ /// assert_eq!(it.next(), Some(24) );
420+ /// assert_eq!(it.next(), Some( 120) );
421421 /// assert!(it.next().is_none());
422422 /// ```
423423 #[ inline]
@@ -654,7 +654,7 @@ pub trait Iterator {
654654 /// ```
655655 /// let a = [1, 2, 3, 4, 5];
656656 /// let mut it = a.iter();
657- /// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3 );
657+ /// assert_eq!(it.find(|&x| *x == 3), Some(&3) );
658658 /// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
659659 #[ inline]
660660 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -677,7 +677,7 @@ pub trait Iterator {
677677 /// ```
678678 /// let a = [1, 2, 3, 4, 5];
679679 /// let mut it = a.iter();
680- /// assert_eq!(it.position(|x| *x == 3).unwrap(), 2 );
680+ /// assert_eq!(it.position(|x| *x == 3), Some(2) );
681681 /// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
682682 #[ inline]
683683 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -706,7 +706,7 @@ pub trait Iterator {
706706 /// ```
707707 /// let a = [1, 2, 2, 4, 5];
708708 /// let mut it = a.iter();
709- /// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2 );
709+ /// assert_eq!(it.rposition(|x| *x == 2), Some(2) );
710710 /// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
711711 #[ inline]
712712 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -734,7 +734,7 @@ pub trait Iterator {
734734 ///
735735 /// ```
736736 /// let a = [1, 2, 3, 4, 5];
737- /// assert !(a.iter().max().unwrap() == &5 );
737+ /// assert_eq !(a.iter().max(), Some(&5) );
738738 /// ```
739739 #[ inline]
740740 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -757,7 +757,7 @@ pub trait Iterator {
757757 ///
758758 /// ```
759759 /// let a = [1, 2, 3, 4, 5];
760- /// assert !(a.iter().min().unwrap() == &1 );
760+ /// assert_eq !(a.iter().min(), Some(&1) );
761761 /// ```
762762 #[ inline]
763763 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -986,9 +986,9 @@ pub trait Iterator {
986986 /// ```
987987 /// let a = [1, 2];
988988 /// let mut it = a.iter().cycle();
989- /// assert_eq!(it.next().unwrap(), &1 );
990- /// assert_eq!(it.next().unwrap(), &2 );
991- /// assert_eq!(it.next().unwrap(), &1 );
989+ /// assert_eq!(it.next(), Some(&1) );
990+ /// assert_eq!(it.next(), Some(&2) );
991+ /// assert_eq!(it.next(), Some(&1) );
992992 /// ```
993993 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
994994 #[ inline]
0 commit comments