Trait core::ops::IndexMutUnstable
[-]
[+]
[src]
pub trait IndexMut<Index: ?Sized> {
type Output: ?Sized;
fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Output;
}The IndexMut trait is used to specify the functionality of indexing
operations like arr[idx], when used in a mutable context.
Example
A trivial implementation of IndexMut. When Foo[Foo] happens, it ends up
calling index_mut, and therefore, main prints Indexing!.
#![feature(associated_types)] use std::ops::IndexMut; #[derive(Copy)] struct Foo; impl IndexMut<Foo> for Foo { type Output = Foo; fn index_mut<'a>(&'a mut self, _index: &Foo) -> &'a mut Foo { println!("Indexing!"); self } } fn main() { &mut Foo[Foo]; }
Associated Types
type Output: ?Sized
Required Methods
fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Output
The method for the indexing (Foo[Bar]) operation
Implementors
impl<T> IndexMut<usize> for [T]impl<T> IndexMut<Range<usize>> for [T]impl<T> IndexMut<RangeTo<usize>> for [T]impl<T> IndexMut<RangeFrom<usize>> for [T]impl<T> IndexMut<FullRange> for [T]impl<'a, T> IndexMut<Range<usize>> for IterMut<'a, T>impl<'a, T> IndexMut<RangeTo<usize>> for IterMut<'a, T>impl<'a, T> IndexMut<RangeFrom<usize>> for IterMut<'a, T>impl<'a, T> IndexMut<FullRange> for IterMut<'a, T>