Struct Enumerate
struct Enumerate<I> { ... }
An iterator that yields the current count and the element during iteration.
This struct is created by the enumerate method on Iterator. See its
documentation for more.
Implementations
impl<I> Enumerate<I>
fn next_index(self: &Self) -> usizeRetrieve the current position of the iterator.
If the iterator has not advanced, the position returned will be 0.
The position may also exceed the bounds of the iterator to allow for calculating the displacement of the iterator from following calls to
Iterator::next.Examples
let arr = ; let mut iter = arr.iter.enumerate; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;
impl<I> DoubleEndedIterator for Enumerate<I>
fn next_back(self: &mut Self) -> Option<(usize, <I as Iterator>::Item)>fn nth_back(self: &mut Self, n: usize) -> Option<(usize, <I as Iterator>::Item)>fn try_rfold<Acc, Fold, R>(self: &mut Self, init: Acc, fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, <Self as >::Item) -> R, R: Try<Output = Acc>fn rfold<Acc, Fold>(self: Self, init: Acc, fold: Fold) -> Acc where Fold: FnMut(Acc, <Self as >::Item) -> Accfn advance_back_by(self: &mut Self, n: usize) -> Result<(), NonZero<usize>>
impl<I> ExactSizeIterator for Enumerate<I>
fn len(self: &Self) -> usizefn is_empty(self: &Self) -> bool
impl<I> Freeze for Enumerate<I>
impl<I> FusedIterator for Enumerate<I>
impl<I> IntoIterator for Enumerate<I>
fn into_iter(self: Self) -> I
impl<I> Iterator for Enumerate<I>
fn next(self: &mut Self) -> Option<(usize, <I as Iterator>::Item)>Overflow Behavior
The method does no guarding against overflows, so enumerating more than
usize::MAXelements either produces the wrong result or panics. If overflow checks are enabled, a panic is guaranteed.Panics
Might panic if the index of the element overflows a
usize.fn size_hint(self: &Self) -> (usize, Option<usize>)fn nth(self: &mut Self, n: usize) -> Option<(usize, <I as >::Item)>fn count(self: Self) -> usizefn try_fold<Acc, Fold, R>(self: &mut Self, init: Acc, fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, <Self as >::Item) -> R, R: Try<Output = Acc>fn fold<Acc, Fold>(self: Self, init: Acc, fold: Fold) -> Acc where Fold: FnMut(Acc, <Self as >::Item) -> Accfn advance_by(self: &mut Self, n: usize) -> Result<(), NonZero<usize>>
impl<I> RefUnwindSafe for Enumerate<I>
impl<I> Send for Enumerate<I>
impl<I> Sync for Enumerate<I>
impl<I> TrustedLen for Enumerate<I>
impl<I> Unpin for Enumerate<I>
impl<I> UnsafeUnpin for Enumerate<I>
impl<I> UnwindSafe for Enumerate<I>
impl<I: $crate::clone::Clone> Clone for Enumerate<I>
fn clone(self: &Self) -> Enumerate<I>
impl<I: $crate::fmt::Debug> Debug for Enumerate<I>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<I: Default> Default for Enumerate<I>
fn default() -> SelfCreates an
Enumerateiterator from the default value ofI# use slice; # use Enumerate; let iter: = Defaultdefault; assert_eq!;
impl<T> Any for Enumerate<I>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Enumerate<I>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Enumerate<I>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Enumerate<I>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Enumerate<I>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Enumerate<I>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Enumerate<I>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Enumerate<I>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>