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>