Trait eclectic::map::Map
[−]
[src]
pub trait Map<Q: ?Sized = Self::Key>: Base { fn get(&self, key: &Q) -> Option<&Self::Value>; fn get_mut(&mut self, key: &Q) -> Option<&mut Self::Value> where Self: Mut; fn remove(&mut self, key: &Q) -> Option<Self::Value> where Self: Own; fn contains_key(&self, key: &Q) -> bool { ... } }
A map.
A map is a set of keys, each of which is associated with a value.
The type parameter Q
represents an "equivalence" type that can be used to look up values
in the map. For example, given a Map<Key = String>
, it is usually possible to look up
items using a str
. When omitted, Q
defaults to Self::Key
.
Required Methods
fn get(&self, key: &Q) -> Option<&Self::Value>
Returns a reference to the value of the key in the map that is equivalent to the given key.
Returns None
if the map contains no such key.
fn get_mut(&mut self, key: &Q) -> Option<&mut Self::Value> where Self: Mut
Returns a mutable reference to the value of the key in the map that is equivalent to the given key.
Returns None
if the map contains no such key.
fn remove(&mut self, key: &Q) -> Option<Self::Value> where Self: Own
Removes the key in the map that is equivalent to the given key and returns its value.
Returns None
if the map contained no such key.
Provided Methods
fn contains_key(&self, key: &Q) -> bool
Checks if the map contains a key that is equivalent to the given key.