Iter

Struct Iter 

1.6.0 · Source
pub struct Iter<'a, T: 'a> { /* private fields */ }
Expand description

Immutable slice iterator

This struct is created by the iter method on slices.

§Examples

Basic usage:

// First, we need a slice to call the `iter` method on:
let slice = &[1, 2, 3];

// Then we call `iter` on the slice to get the `Iter` iterator,
// and iterate over it:
for element in slice.iter() {
    println!("{element}");
}

// This for loop actually already works without calling `iter`:
for element in slice {
    println!("{element}");
}

Trait Implementations§

1.0.0 · Source§

impl<'a, T> Iterator for Iter<'a, T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

fn next(&mut self) -> Option<&'a T>

Advances the iterator and returns the next value. Read more
1.0.0 · Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the iterator. Read more
1.0.0 · Source§

fn map<B, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> B,

Takes a closure and creates an iterator which calls that closure on each element. Read more
1.0.0 · Source§

fn cloned<'a, T>(self) -> Cloned<Self>
where T: Clone + 'a, Self: Sized + Iterator<Item = &'a T>,

Creates an iterator which clones all of its elements. Read more
1.0.0 · Source§

impl<T: Sync> Send for Iter<'_, T>

1.0.0 · Source§

impl<T: Sync> Sync for Iter<'_, T>

Source§

impl<T> TrustedLen for Iter<'_, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for Iter<'a, T>

§

impl<'a, T> Unpin for Iter<'a, T>
where T: Unpin,

Blanket Implementations§

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<I> IntoIterator for I
where I: Iterator,

Source§

type Item = <I as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = I

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> I

Creates an iterator from a value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.