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>
impl<'a, T> Iterator for Iter<'a, T>
Source§fn next(&mut self) -> Option<&'a T>
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>)
fn size_hint(&self) -> (usize, Option<usize>)
Returns the bounds on the remaining length of the iterator. Read more