Map

Trait Map 

Source
pub trait Map<K, V> {
    type Error: Debug;

    // Required methods
    fn insert(&mut self, key: K, value: V) -> Result<Option<V>, Self::Error>;
    fn get(&self, key: &K) -> Option<&V>;
    fn get_mut(&mut self, key: &K) -> Option<&mut V>;
    fn remove(&mut self, key: &K) -> Option<V>;
    fn clear(&mut self) -> Result<(), Self::Error>;
    fn is_empty(&self) -> bool;
    fn capacity(&self) -> Option<usize>;
    fn len(&self) -> usize;
}
Expand description

An abstract mapping from a set of keys to a set of values.

Required Associated Types§

Source

type Error: Debug

Associated error type.

Required Methods§

Source

fn insert(&mut self, key: K, value: V) -> Result<Option<V>, Self::Error>

Inserts a new key/value pair into this map.

Source

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

Returns an immutable reference to the value associated with the given key.

Source

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

Returns a mutable reference to the value associated with the given key.

Source

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

Removes the key/value pair associated with the given key from this map.

Source

fn clear(&mut self) -> Result<(), Self::Error>

Removes all key/value pairs stored in this map.

Source

fn is_empty(&self) -> bool

Returns whether this map is empty.

Source

fn capacity(&self) -> Option<usize>

Returns the number of key/value pairs this map is capable of storing.

Source

fn len(&self) -> usize

Rethrns the number of key/value pairs currently stored in this map.

Implementors§

Source§

impl<K: Ord, V> Map<K, V> for AllocBTreeMap<K, V>