Trait CopyMap

Source
pub trait CopyMap<K, V>: Container
where K: Copy + Eq,
{ // Required methods fn get(&self, key: K) -> Option<&V>; fn get_mut(&mut self, key: K) -> Option<&mut V>; fn insert(&mut self, k: K, v: V) -> Option<V>; }
Expand description

Trait for a container indexed by a value that implements Copy and Eq.

Required Methods§

Source

fn get(&self, key: K) -> Option<&V>

Get a reference to a value from this map.

Takes a key by value and returns a reference to the corresponding data, or None if the key doesn’t exist in the map.

Source

fn get_mut(&mut self, key: K) -> Option<&mut V>

Get a mutable reference to a value from this map.

Takes a key by value and returns a mutable reference to the corresponding data, or None if the key doesn’t exist in the map.

Source

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.

Implementors§