Trait generational_cache::map::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§
Required Methods§
sourcefn insert(&mut self, key: K, value: V) -> Result<Option<V>, Self::Error>
fn insert(&mut self, key: K, value: V) -> Result<Option<V>, Self::Error>
Inserts a new key/value pair into this map.
sourcefn get(&self, key: &K) -> Option<&V>
fn get(&self, key: &K) -> Option<&V>
Returns an immutable reference to the value associated with the given key.
sourcefn get_mut(&mut self, key: &K) -> Option<&mut V>
fn get_mut(&mut self, key: &K) -> Option<&mut V>
Returns a mutable reference to the value associated with the given key.
sourcefn remove(&mut self, key: &K) -> Option<V>
fn remove(&mut self, key: &K) -> Option<V>
Removes the key/value pair associated with the given key from this map.