[−][src]Trait containers_rs::Map
Trait for a container indexed by a value. The value that indexes the container must implement the Eq trait to. Supports insertion,
Required methods
fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
K: Borrow<Q>,
Q: Eq,
K: Borrow<Q>,
Q: Eq,
Get a value from this Map. Takes a key by reference
and returns a reference to the corresponding data,
or None
if none exists.
fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V> where
K: Borrow<Q>,
Q: Eq,
K: Borrow<Q>,
Q: Eq,
Returns a mutable reference to an object stored in
this container based on the key given, or None
if
the key does not exist.
fn insert(&mut self, k: K, v: V) -> Option<V>
Adds a new item into this container with the associated key, and returns the previous value associated with that key, if it existed.
fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V> where
K: Borrow<Q>,
Q: Eq,
K: Borrow<Q>,
Q: Eq,
Removes an item from this container using the associated key, and returns it (if it existed).
Provided methods
fn contains<Q: ?Sized>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Eq,
K: Borrow<Q>,
Q: Eq,
Returns true if this container contains the key.