@@ -124,7 +124,7 @@ pub trait Iterator {
124
124
///
125
125
/// ```
126
126
/// let a = [1, 2, 3, 4, 5];
127
- /// assert !(a.iter().last().unwrap() == &5 );
127
+ /// assert_eq !(a.iter().last(), Some(&5) );
128
128
/// ```
129
129
#[ inline]
130
130
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -142,8 +142,8 @@ pub trait Iterator {
142
142
/// ```
143
143
/// let a = [1, 2, 3, 4, 5];
144
144
/// 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);
147
147
/// ```
148
148
#[ inline]
149
149
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -165,8 +165,8 @@ pub trait Iterator {
165
165
/// let a = [0];
166
166
/// let b = [1];
167
167
/// 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) );
170
170
/// assert!(it.next().is_none());
171
171
/// ```
172
172
#[ inline]
@@ -188,7 +188,7 @@ pub trait Iterator {
188
188
/// let a = [0];
189
189
/// let b = [1];
190
190
/// let mut it = a.iter().zip(b.iter());
191
- /// assert_eq!(it.next().unwrap(), ( &0, &1));
191
+ /// assert_eq!(it.next(), Some(( &0, &1) ));
192
192
/// assert!(it.next().is_none());
193
193
/// ```
194
194
///
@@ -221,8 +221,8 @@ pub trait Iterator {
221
221
/// ```
222
222
/// let a = [1, 2];
223
223
/// 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) );
226
226
/// assert!(it.next().is_none());
227
227
/// ```
228
228
#[ inline]
@@ -242,7 +242,7 @@ pub trait Iterator {
242
242
/// ```
243
243
/// let a = [1, 2];
244
244
/// let mut it = a.iter().filter(|&x| *x > 1);
245
- /// assert_eq!(it.next().unwrap(), &2 );
245
+ /// assert_eq!(it.next(), Some(&2) );
246
246
/// assert!(it.next().is_none());
247
247
/// ```
248
248
#[ inline]
@@ -262,7 +262,7 @@ pub trait Iterator {
262
262
/// ```
263
263
/// let a = [1, 2];
264
264
/// 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) );
266
266
/// assert!(it.next().is_none());
267
267
/// ```
268
268
#[ inline]
@@ -286,8 +286,8 @@ pub trait Iterator {
286
286
/// ```
287
287
/// let a = [100, 200];
288
288
/// 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) ));
291
291
/// assert!(it.next().is_none());
292
292
/// ```
293
293
#[ inline]
@@ -329,9 +329,9 @@ pub trait Iterator {
329
329
/// ```
330
330
/// let a = [1, 2, 3, 4, 5];
331
331
/// 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) );
335
335
/// assert!(it.next().is_none());
336
336
/// ```
337
337
#[ inline]
@@ -351,8 +351,8 @@ pub trait Iterator {
351
351
/// ```
352
352
/// let a = [1, 2, 3, 4, 5];
353
353
/// 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) );
356
356
/// assert!(it.next().is_none());
357
357
/// ```
358
358
#[ inline]
@@ -371,8 +371,8 @@ pub trait Iterator {
371
371
/// ```
372
372
/// let a = [1, 2, 3, 4, 5];
373
373
/// 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) );
376
376
/// assert!(it.next().is_none());
377
377
/// ```
378
378
#[ inline]
@@ -389,9 +389,9 @@ pub trait Iterator {
389
389
/// ```
390
390
/// let a = [1, 2, 3, 4, 5];
391
391
/// 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) );
395
395
/// assert!(it.next().is_none());
396
396
/// ```
397
397
#[ inline]
@@ -413,11 +413,11 @@ pub trait Iterator {
413
413
/// *fac = *fac * x;
414
414
/// Some(*fac)
415
415
/// });
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) );
421
421
/// assert!(it.next().is_none());
422
422
/// ```
423
423
#[ inline]
@@ -654,7 +654,7 @@ pub trait Iterator {
654
654
/// ```
655
655
/// let a = [1, 2, 3, 4, 5];
656
656
/// 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) );
658
658
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
659
659
#[ inline]
660
660
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -677,7 +677,7 @@ pub trait Iterator {
677
677
/// ```
678
678
/// let a = [1, 2, 3, 4, 5];
679
679
/// 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) );
681
681
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
682
682
#[ inline]
683
683
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -706,7 +706,7 @@ pub trait Iterator {
706
706
/// ```
707
707
/// let a = [1, 2, 2, 4, 5];
708
708
/// 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) );
710
710
/// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
711
711
#[ inline]
712
712
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -734,7 +734,7 @@ pub trait Iterator {
734
734
///
735
735
/// ```
736
736
/// let a = [1, 2, 3, 4, 5];
737
- /// assert !(a.iter().max().unwrap() == &5 );
737
+ /// assert_eq !(a.iter().max(), Some(&5) );
738
738
/// ```
739
739
#[ inline]
740
740
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -757,7 +757,7 @@ pub trait Iterator {
757
757
///
758
758
/// ```
759
759
/// let a = [1, 2, 3, 4, 5];
760
- /// assert !(a.iter().min().unwrap() == &1 );
760
+ /// assert_eq !(a.iter().min(), Some(&1) );
761
761
/// ```
762
762
#[ inline]
763
763
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -986,9 +986,9 @@ pub trait Iterator {
986
986
/// ```
987
987
/// let a = [1, 2];
988
988
/// 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) );
992
992
/// ```
993
993
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
994
994
#[ inline]
0 commit comments