Trait std::ops::IndexMutStable
[-]
[+]
[src]
pub trait IndexMut<Index> where Index: ?Sized {
type Output;
fn index_mut(&'a mut self, index: &Index) -> &'a mut <Self as IndexMut<Index>>::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[Bar] happens, it ends up
calling index_mut, and therefore, main prints Indexing!.
use std::ops::IndexMut; #[derive(Copy)] struct Foo; struct Bar; impl IndexMut<Bar> for Foo { type Output = Foo; fn index_mut<'a>(&'a mut self, _index: &Bar) -> &'a mut Foo { println!("Indexing!"); self } } fn main() { &mut Foo[Bar]; }
Associated Types
Required Methods
fn index_mut(&'a mut self, index: &Index) -> &'a mut <Self as IndexMut<Index>>::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<RangeFull> 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<RangeFull> for IterMut<'a, T>impl<K, Q, V> IndexMut<Q> for BTreeMap<K, V> where K: Ord, Q: BorrowFrom<K>, Q: Ord, Q: ?Sizedimpl<A> IndexMut<usize> for RingBuf<A>impl<T> IndexMut<usize> for Vec<T>impl<T> IndexMut<Range<usize>> for Vec<T>impl<T> IndexMut<RangeTo<usize>> for Vec<T>impl<T> IndexMut<RangeFrom<usize>> for Vec<T>impl<T> IndexMut<RangeFull> for Vec<T>impl<V> IndexMut<usize> for VecMap<V>impl<K, V, S, H, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S> where K: Eq + Hash<H>, Q: Eq + Hash<H> + BorrowFrom<K>, S: HashState<Hasher=H>, H: Hasher<Output=u64>impl<K, V, S, H, Q: ?Sized> IndexMut<Q> for HashMap<K, V, S> where K: Eq + Hash<H>, Q: Eq + Hash<H> + BorrowFrom<K>, S: HashState<Hasher=H>, H: Hasher<Output=u64>