Trait std::collections::MutableMap[src]

pub trait MutableMap<K, V>: Map<K, V> + Mutable {
    fn swap<K, V>(&mut self, k: K, v: V) -> Option<V>;
    fn pop<K, V>(&mut self, k: &K) -> Option<V>;
    fn find_mut<K, V>(&'a mut self, key: &K) -> Option<&'a mut V>;

    fn insert<K, V>(&mut self, key: K, value: V) -> bool { ... }
    fn remove<K, V>(&mut self, key: &K) -> bool { ... }
}

This trait provides basic operations to modify the contents of a map.

Required Methods

fn swap<K, V>(&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<K, V>(&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<K, V>(&'a mut self, key: &K) -> Option<&'a mut V>

Return a mutable reference to the value corresponding to the key

Provided Methods

fn insert<K, V>(&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<K, V>(&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.

Implementors