File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,27 @@ impl<I> Enumerate<I> {
30
30
///
31
31
/// The position may also exceed the bounds of the iterator to allow for calculating
32
32
/// the displacement of the iterator from following calls to [`Iterator::next`].
33
+ ///
34
+ /// # Examples
35
+ ///
36
+ /// ```
37
+ /// #![feature(next_index)]
38
+ ///
39
+ /// let arr = ['a', 'b'];
40
+ ///
41
+ /// let mut iter = arr.iter().enumerate();
42
+ ///
43
+ /// assert_eq!(iter.next_index(), 0);
44
+ /// assert_eq!(iter.next(), Some((0, &'a')));
45
+ ///
46
+ /// assert_eq!(iter.next_index(), 1);
47
+ /// assert_eq!(iter.next_index(), 1);
48
+ /// assert_eq!(iter.next(), Some((1, &'b')));
49
+ ///
50
+ /// assert_eq!(iter.next_index(), 2);
51
+ /// assert_eq!(iter.next(), None);
52
+ /// assert_eq!(iter.next_index(), 2);
53
+ /// ```
33
54
#[ inline]
34
55
#[ unstable( feature = "next_index" , issue = "130711" ) ]
35
56
pub fn next_index ( & self ) -> usize {
You can’t perform that action at this time.
0 commit comments