pub trait ArrayMut: Array + IndexMut<usize> {
    // Provided methods
    fn get_mut(&mut self, index: usize) -> Option<&mut Self::Output> { ... }
    fn first_mut(&mut self) -> Option<&mut Self::Output> { ... }
    fn last_mut(&mut self) -> Option<&mut Self::Output> { ... }
    fn set(&mut self, index: usize, value: Self::Output) -> Option<Self::Output>
       where Self::Output: Sized { ... }
    fn swap(&mut self, index1: usize, index2: usize)
       where Self::Output: Sized { ... }
    fn map_pair<F, A>(&mut self, index1: usize, index2: usize, f: F) -> A
       where F: FnMut(&mut Self::Output, &mut Self::Output) -> A { ... }
    fn sort_unstable(&mut self)
       where Self::Output: Ord + Sized { ... }
    fn sort_unstable_by<F>(&mut self, compare: F)
       where Self::Output: Sized,
             F: FnMut(&Self::Output, &Self::Output) -> Ordering { ... }
    fn sort_unstable_by_key<F, K>(&mut self, extract: F)
       where F: FnMut(&Self::Output) -> K,
             K: Ord,
             Self::Output: Sized { ... }
}
Expand description

Trait for arrays with mutable indexes.

Provided Methods§

source

fn get_mut(&mut self, index: usize) -> Option<&mut Self::Output>

Get a mutable reference to the element at the given index.

source

fn first_mut(&mut self) -> Option<&mut Self::Output>

Get a mutable reference to the first element in the array.

source

fn last_mut(&mut self) -> Option<&mut Self::Output>

Get a mutable reference to the last element in the array.

source

fn set(&mut self, index: usize, value: Self::Output) -> Option<Self::Output>
where Self::Output: Sized,

Set the value of the element at the given index.

Returns the previous value, or None if the index is out of bounds.

source

fn swap(&mut self, index1: usize, index2: usize)
where Self::Output: Sized,

Swap the elements at two indexes.

source

fn map_pair<F, A>(&mut self, index1: usize, index2: usize, f: F) -> A
where F: FnMut(&mut Self::Output, &mut Self::Output) -> A,

Get mutable references to the elements at two indexes and call a function on them.

This provides a safe way to get two mutable references into an array at the same time, which would normally be disallowed by the borrow checker.

source

fn sort_unstable(&mut self)
where Self::Output: Ord + Sized,

Sort the elements of the array.

source

fn sort_unstable_by<F>(&mut self, compare: F)
where Self::Output: Sized, F: FnMut(&Self::Output, &Self::Output) -> Ordering,

Sort the elements of the array using a comparator function.

source

fn sort_unstable_by_key<F, K>(&mut self, extract: F)
where F: FnMut(&Self::Output) -> K, K: Ord, Self::Output: Sized,

Sort the elements of the array using a key extractor function.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<A> ArrayMut for VecDeque<A>

source§

fn get_mut( &mut self, index: usize ) -> Option<&mut <VecDeque<A> as Index<usize>>::Output>

source§

fn swap(&mut self, index1: usize, index2: usize)
where <VecDeque<A> as Index<usize>>::Output: Sized,

Implementors§

source§

impl<'a, A: 'a, const N: usize> ArrayMut for SliceMut<'a, A, N>

source§

impl<A, const N: usize> ArrayMut for RingBuffer<A, N>