Trait std::ops::IndexMutExperimental
[-]
[+]
[src]
pub trait IndexMut<Index, Result> { fn index_mut(&'a mut self, index: &Index) -> &'a mut Result; }
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!
.
#[deriving(Copy)] struct Foo; impl IndexMut<Foo, Foo> for Foo { fn index_mut<'a>(&'a mut self, _index: &Foo) -> &'a mut Foo { println!("Indexing!"); self } } fn main() { &mut Foo[Foo]; }
Required Methods
fn index_mut(&'a mut self, index: &Index) -> &'a mut Result
The method for the indexing (Foo[Bar]
) operation
Implementors
impl<T> IndexMut<uint, T> for [T]
impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> IndexMut<Q, V> for HashMap<K, V, H> where Q: BorrowFrom<K> + Hash<S> + Eq
impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> IndexMut<Q, V> for HashMap<K, V, H> where Q: BorrowFrom<K> + Hash<S> + Eq
impl<K: Ord, Q, V> IndexMut<Q, V> for BTreeMap<K, V>
impl<A> IndexMut<uint, A> for RingBuf<A>
impl<T> IndexMut<uint, T> for Vec<T>
impl<V> IndexMut<uint, V> for VecMap<V>