@@ -137,7 +137,7 @@ pub trait Iterator {
137137 ///
138138 /// ```
139139 /// let a = [1, 2, 3, 4, 5];
140- /// assert_eq!(a.iter().last().unwrap(), &5 );
140+ /// assert_eq!(a.iter().last(), Some(&5) );
141141 /// ```
142142 #[ inline]
143143 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -155,7 +155,7 @@ pub trait Iterator {
155155 /// ```
156156 /// let a = [1, 2, 3, 4, 5];
157157 /// let mut it = a.iter();
158- /// assert_eq!(it.nth(2).unwrap(), &3 );
158+ /// assert_eq!(it.nth(2), Some(&3) );
159159 /// assert_eq!(it.nth(2), None);
160160 /// ```
161161 #[ inline]
@@ -178,8 +178,8 @@ pub trait Iterator {
178178 /// let a = [0];
179179 /// let b = [1];
180180 /// let mut it = a.iter().chain(b.iter());
181- /// assert_eq!(it.next().unwrap(), &0 );
182- /// assert_eq!(it.next().unwrap(), &1 );
181+ /// assert_eq!(it.next(), Some(&0) );
182+ /// assert_eq!(it.next(), Some(&1) );
183183 /// assert!(it.next().is_none());
184184 /// ```
185185 #[ inline]
@@ -201,7 +201,7 @@ pub trait Iterator {
201201 /// let a = [0];
202202 /// let b = [1];
203203 /// let mut it = a.iter().zip(b.iter());
204- /// assert_eq!(it.next().unwrap(), ( &0, &1));
204+ /// assert_eq!(it.next(), Some(( &0, &1) ));
205205 /// assert!(it.next().is_none());
206206 /// ```
207207 ///
@@ -234,8 +234,8 @@ pub trait Iterator {
234234 /// ```
235235 /// let a = [1, 2];
236236 /// let mut it = a.iter().map(|&x| 2 * x);
237- /// assert_eq!(it.next().unwrap(), 2 );
238- /// assert_eq!(it.next().unwrap(), 4 );
237+ /// assert_eq!(it.next(), Some(2) );
238+ /// assert_eq!(it.next(), Some(4) );
239239 /// assert!(it.next().is_none());
240240 /// ```
241241 #[ inline]
@@ -255,7 +255,7 @@ pub trait Iterator {
255255 /// ```
256256 /// let a = [1, 2];
257257 /// let mut it = a.iter().filter(|&x| *x > 1);
258- /// assert_eq!(it.next().unwrap(), &2 );
258+ /// assert_eq!(it.next(), Some(&2) );
259259 /// assert!(it.next().is_none());
260260 /// ```
261261 #[ inline]
@@ -275,7 +275,7 @@ pub trait Iterator {
275275 /// ```
276276 /// let a = [1, 2];
277277 /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None});
278- /// assert_eq!(it.next().unwrap(), 4 );
278+ /// assert_eq!(it.next(), Some(4) );
279279 /// assert!(it.next().is_none());
280280 /// ```
281281 #[ inline]
@@ -310,8 +310,8 @@ pub trait Iterator {
310310 /// ```
311311 /// let a = [100, 200];
312312 /// let mut it = a.iter().enumerate();
313- /// assert_eq!(it.next().unwrap(), ( 0, &100));
314- /// assert_eq!(it.next().unwrap(), ( 1, &200));
313+ /// assert_eq!(it.next(), Some(( 0, &100) ));
314+ /// assert_eq!(it.next(), Some(( 1, &200) ));
315315 /// assert!(it.next().is_none());
316316 /// ```
317317 #[ inline]
@@ -329,12 +329,12 @@ pub trait Iterator {
329329 /// # #![feature(core)]
330330 /// let xs = [100, 200, 300];
331331 /// let mut it = xs.iter().cloned().peekable();
332- /// assert_eq!(*it.peek().unwrap(), 100);
333- /// assert_eq!(it.next().unwrap(), 100);
334- /// assert_eq!(it.next().unwrap(), 200);
335- /// assert_eq!(*it.peek().unwrap(), 300);
336- /// assert_eq!(*it.peek().unwrap(), 300);
337- /// assert_eq!(it.next().unwrap(), 300);
332+ /// assert_eq!(*it.peek(), Some( 100) );
333+ /// assert_eq!(it.next(), Some( 100) );
334+ /// assert_eq!(it.next(), Some( 200) );
335+ /// assert_eq!(*it.peek(), Some( 300) );
336+ /// assert_eq!(*it.peek(), Some( 300) );
337+ /// assert_eq!(it.next(), Some( 300) );
338338 /// assert!(it.peek().is_none());
339339 /// assert!(it.next().is_none());
340340 /// ```
@@ -353,9 +353,9 @@ pub trait Iterator {
353353 /// ```
354354 /// let a = [1, 2, 3, 4, 5];
355355 /// let mut it = a.iter().skip_while(|&a| *a < 3);
356- /// assert_eq!(it.next().unwrap(), &3 );
357- /// assert_eq!(it.next().unwrap(), &4 );
358- /// assert_eq!(it.next().unwrap(), &5 );
356+ /// assert_eq!(it.next(), Some(&3) );
357+ /// assert_eq!(it.next(), Some(&4) );
358+ /// assert_eq!(it.next(), Some(&5) );
359359 /// assert!(it.next().is_none());
360360 /// ```
361361 #[ inline]
@@ -375,8 +375,8 @@ pub trait Iterator {
375375 /// ```
376376 /// let a = [1, 2, 3, 4, 5];
377377 /// let mut it = a.iter().take_while(|&a| *a < 3);
378- /// assert_eq!(it.next().unwrap(), &1 );
379- /// assert_eq!(it.next().unwrap(), &2 );
378+ /// assert_eq!(it.next(), Some(&1) );
379+ /// assert_eq!(it.next(), Some(&2) );
380380 /// assert!(it.next().is_none());
381381 /// ```
382382 #[ inline]
@@ -395,8 +395,8 @@ pub trait Iterator {
395395 /// ```
396396 /// let a = [1, 2, 3, 4, 5];
397397 /// let mut it = a.iter().skip(3);
398- /// assert_eq!(it.next().unwrap(), &4 );
399- /// assert_eq!(it.next().unwrap(), &5 );
398+ /// assert_eq!(it.next(), Some(&4) );
399+ /// assert_eq!(it.next(), Some(&5) );
400400 /// assert!(it.next().is_none());
401401 /// ```
402402 #[ inline]
@@ -413,9 +413,9 @@ pub trait Iterator {
413413 /// ```
414414 /// let a = [1, 2, 3, 4, 5];
415415 /// let mut it = a.iter().take(3);
416- /// assert_eq!(it.next().unwrap(), &1 );
417- /// assert_eq!(it.next().unwrap(), &2 );
418- /// assert_eq!(it.next().unwrap(), &3 );
416+ /// assert_eq!(it.next(), Some(&1) );
417+ /// assert_eq!(it.next(), Some(&2) );
418+ /// assert_eq!(it.next(), Some(&3) );
419419 /// assert!(it.next().is_none());
420420 /// ```
421421 #[ inline]
@@ -437,11 +437,11 @@ pub trait Iterator {
437437 /// *fac = *fac * x;
438438 /// Some(*fac)
439439 /// });
440- /// assert_eq!(it.next().unwrap(), 1 );
441- /// assert_eq!(it.next().unwrap(), 2 );
442- /// assert_eq!(it.next().unwrap(), 6 );
443- /// assert_eq!(it.next().unwrap(), 24 );
444- /// assert_eq!(it.next().unwrap(), 120);
440+ /// assert_eq!(it.next(), Some(1) );
441+ /// assert_eq!(it.next(), Some(2) );
442+ /// assert_eq!(it.next(), Some(6) );
443+ /// assert_eq!(it.next(), Some(24) );
444+ /// assert_eq!(it.next(), Some( 120) );
445445 /// assert!(it.next().is_none());
446446 /// ```
447447 #[ inline]
@@ -680,7 +680,7 @@ pub trait Iterator {
680680 /// ```
681681 /// let a = [1, 2, 3, 4, 5];
682682 /// let mut it = a.iter();
683- /// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3 );
683+ /// assert_eq!(it.find(|&x| *x == 3), Some(&3) );
684684 /// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
685685 #[ inline]
686686 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -715,7 +715,7 @@ pub trait Iterator {
715715 /// ```
716716 /// let a = [1, 2, 3, 4, 5];
717717 /// let mut it = a.iter();
718- /// assert_eq!(it.position(|x| *x == 3).unwrap(), 2 );
718+ /// assert_eq!(it.position(|x| *x == 3), Some(2) );
719719 /// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
720720 #[ inline]
721721 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -743,7 +743,7 @@ pub trait Iterator {
743743 /// ```
744744 /// let a = [1, 2, 2, 4, 5];
745745 /// let mut it = a.iter();
746- /// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2 );
746+ /// assert_eq!(it.rposition(|x| *x == 2), Some(2) );
747747 /// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
748748 #[ inline]
749749 #[ 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_eq!(a.iter().max().unwrap(), &5 );
776+ /// assert_eq!(a.iter().max(), Some(&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_eq!(a.iter().min().unwrap(), &1 );
799+ /// assert_eq!(a.iter().min(), Some(&1) );
800800 /// ```
801801 #[ inline]
802802 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -900,7 +900,7 @@ pub trait Iterator {
900900 /// # #![feature(core)]
901901 ///
902902 /// let a = [-3_i32, 0, 1, 5, -10];
903- /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
903+ /// assert_eq!(*a.iter().max_by(|x| x.abs()), Some( -10) );
904904 /// ```
905905 #[ inline]
906906 #[ unstable( feature = "core" ,
@@ -929,7 +929,7 @@ pub trait Iterator {
929929 /// # #![feature(core)]
930930 ///
931931 /// let a = [-3_i32, 0, 1, 5, -10];
932- /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0 );
932+ /// assert_eq!(*a.iter().min_by(|x| x.abs()), Some(0) );
933933 /// ```
934934 #[ inline]
935935 #[ unstable( feature = "core" ,
@@ -1025,9 +1025,9 @@ pub trait Iterator {
10251025 /// ```
10261026 /// let a = [1, 2];
10271027 /// let mut it = a.iter().cycle();
1028- /// assert_eq!(it.next().unwrap(), &1 );
1029- /// assert_eq!(it.next().unwrap(), &2 );
1030- /// assert_eq!(it.next().unwrap(), &1 );
1028+ /// assert_eq!(it.next(), Some(&1) );
1029+ /// assert_eq!(it.next(), Some(&2) );
1030+ /// assert_eq!(it.next(), Some(&1) );
10311031 /// ```
10321032 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
10331033 #[ inline]
0 commit comments