IterMut

Struct IterMut 

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

Mutable slice iterator.

This struct is created by the iter_mut method on slices.

§Examples

Basic usage:

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

// Then we call `iter_mut` on the slice to get the `IterMut` iterator,
// iterate over it and increment each element value:
for element in slice.iter_mut() {
    *element += 1;
}

// We now have "[2, 3, 4]":
println!("{slice:?}");

Trait Implementations§

1.0.0 · Source§

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

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

fn next(&mut self) -> Option<&'a mut 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: Send> Send for IterMut<'_, T>

1.0.0 · Source§

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

Source§

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

Auto Trait Implementations§

§

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

§

impl<'a, T> Unpin for IterMut<'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.