Trait eclectic::map::Base
[−]
[src]
pub trait Base: Collection<Item=(Self::Key, Self::Value)> { type Key; type Value; fn iter<'a>(&'a self) -> Box<Iterator<Item=(&'a Self::Key, &'a Self::Value)> + 'a>; fn iter_mut<'a>(&'a mut self) -> Box<Iterator<Item=(&'a Self::Key, &'a mut Self::Value)> + 'a> where Self: Mutate; fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value> where Self: AddRemove; fn entry<'a>(&'a mut self, key: Self::Key) -> Entry<'a, Self::Key, Self::Value> where Self: AddRemove; }
Map functionality that is independent of an additional type parameter.
It is unusual to use this trait directly. Consider using Map
instead.
This trait exists to prevent the ambiguity that would arise if its methods were instead
implemented on Map
. In that scenario, map.insert(key, value)
would be ambiguous if
the type of map
were M
and M: Map<Q> + Map<R>
.
Associated Types
Required Methods
fn iter<'a>(&'a self) -> Box<Iterator<Item=(&'a Self::Key, &'a Self::Value)> + 'a>
Returns an iterator that yields references to the map's keys and references to their values.
The iteration order is unspecified, but subtraits may place a requirement on it.
fn iter_mut<'a>(&'a mut self) -> Box<Iterator<Item=(&'a Self::Key, &'a mut Self::Value)> + 'a> where Self: Mutate
Returns an iterator that yields references to the map's keys and mutable references to their values.
The iteration order is unspecified, but subtraits may place a requirement on it.
fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value> where Self: AddRemove
Inserts the given key and value into the map without replacing an equivalent key.
If the map contains a key that is equivalent to the given key, that key is not replaced with the given key. The value is always replaced, however.
Returns the equivalent key's value if the map contained one, None
otherwise.
fn entry<'a>(&'a mut self, key: Self::Key) -> Entry<'a, Self::Key, Self::Value> where Self: AddRemove
Returns the entry in the map for the given key.