@@ -137,7 +137,7 @@ pub trait Iterator {
137
137
///
138
138
/// ```
139
139
/// let a = [1, 2, 3, 4, 5];
140
- /// assert_eq!(a.iter().last().unwrap(), &5 );
140
+ /// assert_eq!(a.iter().last(), Some(&5) );
141
141
/// ```
142
142
#[ inline]
143
143
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -155,7 +155,7 @@ pub trait Iterator {
155
155
/// ```
156
156
/// let a = [1, 2, 3, 4, 5];
157
157
/// let mut it = a.iter();
158
- /// assert_eq!(it.nth(2).unwrap(), &3 );
158
+ /// assert_eq!(it.nth(2), Some(&3) );
159
159
/// assert_eq!(it.nth(2), None);
160
160
/// ```
161
161
#[ inline]
@@ -178,8 +178,8 @@ pub trait Iterator {
178
178
/// let a = [0];
179
179
/// let b = [1];
180
180
/// 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) );
183
183
/// assert!(it.next().is_none());
184
184
/// ```
185
185
#[ inline]
@@ -201,7 +201,7 @@ pub trait Iterator {
201
201
/// let a = [0];
202
202
/// let b = [1];
203
203
/// let mut it = a.iter().zip(b.iter());
204
- /// assert_eq!(it.next().unwrap(), ( &0, &1));
204
+ /// assert_eq!(it.next(), Some(( &0, &1) ));
205
205
/// assert!(it.next().is_none());
206
206
/// ```
207
207
///
@@ -234,8 +234,8 @@ pub trait Iterator {
234
234
/// ```
235
235
/// let a = [1, 2];
236
236
/// 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) );
239
239
/// assert!(it.next().is_none());
240
240
/// ```
241
241
#[ inline]
@@ -255,7 +255,7 @@ pub trait Iterator {
255
255
/// ```
256
256
/// let a = [1, 2];
257
257
/// let mut it = a.iter().filter(|&x| *x > 1);
258
- /// assert_eq!(it.next().unwrap(), &2 );
258
+ /// assert_eq!(it.next(), Some(&2) );
259
259
/// assert!(it.next().is_none());
260
260
/// ```
261
261
#[ inline]
@@ -275,7 +275,7 @@ pub trait Iterator {
275
275
/// ```
276
276
/// let a = [1, 2];
277
277
/// 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) );
279
279
/// assert!(it.next().is_none());
280
280
/// ```
281
281
#[ inline]
@@ -310,8 +310,8 @@ pub trait Iterator {
310
310
/// ```
311
311
/// let a = [100, 200];
312
312
/// 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) ));
315
315
/// assert!(it.next().is_none());
316
316
/// ```
317
317
#[ inline]
@@ -329,12 +329,12 @@ pub trait Iterator {
329
329
/// # #![feature(core)]
330
330
/// let xs = [100, 200, 300];
331
331
/// 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) );
338
338
/// assert!(it.peek().is_none());
339
339
/// assert!(it.next().is_none());
340
340
/// ```
@@ -353,9 +353,9 @@ pub trait Iterator {
353
353
/// ```
354
354
/// let a = [1, 2, 3, 4, 5];
355
355
/// 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) );
359
359
/// assert!(it.next().is_none());
360
360
/// ```
361
361
#[ inline]
@@ -375,8 +375,8 @@ pub trait Iterator {
375
375
/// ```
376
376
/// let a = [1, 2, 3, 4, 5];
377
377
/// 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) );
380
380
/// assert!(it.next().is_none());
381
381
/// ```
382
382
#[ inline]
@@ -395,8 +395,8 @@ pub trait Iterator {
395
395
/// ```
396
396
/// let a = [1, 2, 3, 4, 5];
397
397
/// 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) );
400
400
/// assert!(it.next().is_none());
401
401
/// ```
402
402
#[ inline]
@@ -413,9 +413,9 @@ pub trait Iterator {
413
413
/// ```
414
414
/// let a = [1, 2, 3, 4, 5];
415
415
/// 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) );
419
419
/// assert!(it.next().is_none());
420
420
/// ```
421
421
#[ inline]
@@ -437,11 +437,11 @@ pub trait Iterator {
437
437
/// *fac = *fac * x;
438
438
/// Some(*fac)
439
439
/// });
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) );
445
445
/// assert!(it.next().is_none());
446
446
/// ```
447
447
#[ inline]
@@ -680,7 +680,7 @@ pub trait Iterator {
680
680
/// ```
681
681
/// let a = [1, 2, 3, 4, 5];
682
682
/// 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) );
684
684
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
685
685
#[ inline]
686
686
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -715,7 +715,7 @@ pub trait Iterator {
715
715
/// ```
716
716
/// let a = [1, 2, 3, 4, 5];
717
717
/// 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) );
719
719
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
720
720
#[ inline]
721
721
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -743,7 +743,7 @@ pub trait Iterator {
743
743
/// ```
744
744
/// let a = [1, 2, 2, 4, 5];
745
745
/// 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) );
747
747
/// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
748
748
#[ inline]
749
749
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -773,7 +773,7 @@ pub trait Iterator {
773
773
///
774
774
/// ```
775
775
/// let a = [1, 2, 3, 4, 5];
776
- /// assert_eq!(a.iter().max().unwrap(), &5 );
776
+ /// assert_eq!(a.iter().max(), Some(&5) );
777
777
/// ```
778
778
#[ inline]
779
779
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -796,7 +796,7 @@ pub trait Iterator {
796
796
///
797
797
/// ```
798
798
/// let a = [1, 2, 3, 4, 5];
799
- /// assert_eq!(a.iter().min().unwrap(), &1 );
799
+ /// assert_eq!(a.iter().min(), Some(&1) );
800
800
/// ```
801
801
#[ inline]
802
802
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -900,7 +900,7 @@ pub trait Iterator {
900
900
/// # #![feature(core)]
901
901
///
902
902
/// 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) );
904
904
/// ```
905
905
#[ inline]
906
906
#[ unstable( feature = "core" ,
@@ -929,7 +929,7 @@ pub trait Iterator {
929
929
/// # #![feature(core)]
930
930
///
931
931
/// 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) );
933
933
/// ```
934
934
#[ inline]
935
935
#[ unstable( feature = "core" ,
@@ -1025,9 +1025,9 @@ pub trait Iterator {
1025
1025
/// ```
1026
1026
/// let a = [1, 2];
1027
1027
/// 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) );
1031
1031
/// ```
1032
1032
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1033
1033
#[ inline]
0 commit comments