File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 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> {
3030 ///
3131 /// The position may also exceed the bounds of the iterator to allow for calculating
3232 /// 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+ /// ```
3354 #[ inline]
3455 #[ unstable( feature = "next_index" , issue = "130711" ) ]
3556 pub fn next_index ( & self ) -> usize {
You can’t perform that action at this time.
0 commit comments