[−][src]Trait containers_rs::Map
Trait for a container indexed by a value that implements Eq
.
Required methods
fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
K: Borrow<Q>,
Q: Eq,
K: Borrow<Q>,
Q: Eq,
Returns a reference to a value from this Map.
Takes a key by reference
and returns a reference to the corresponding data,
or None
if the key doesn't exist in the map.
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 a value in this map.
Takes a key by reference
and returns a mutable reference to the corresponding data,
or None
if the key doesn't exist in the map.
fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
If the map did not have this key present, None is returned.
If the map did have this key present, the value is updated, and the old value is returned. Note that the key itself isn't necessarily updated.