pub trait MutableMap<K, V>: Map<K, V> + Mutable { fn swap(&mut self, k: K, v: V) -> Option<V>; fn pop(&mut self, k: &K) -> Option<V>; fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V>; fn insert(&mut self, key: K, value: V) -> bool { ... } fn remove(&mut self, key: &K) -> bool { ... } }
This trait provides basic operations to modify the contents of a map.
fn swap(&mut self, k: K, v: V) -> Option<V>
Insert a key-value pair from the map. If the key already had a value present in the map, that value is returned. Otherwise None is returned.
fn pop(&mut self, k: &K) -> Option<V>
Removes a key from the map, returning the value at the key if the key was previously in the map.
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V>
Return a mutable reference to the value corresponding to the key
fn insert(&mut self, key: K, value: V) -> bool
Insert a key-value pair into the map. An existing value for a key is replaced by the new value. Return true if the key did not already exist in the map.
fn remove(&mut self, key: &K) -> bool
Remove a key-value pair from the map. Return true if the key was present in the map, otherwise false.
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).