pub trait Storage<K, V>: Default {
fn insert(&mut self, key: K, value: V) -> Option<V>;
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 for_each_value<F>(&self, f: F)
where
F: FnMut(&V);
}
Expand description
The trait defining how storage works.
Type Arguments
K
is the key being stored.V
is the value being stored.
Required Methods
fn insert(&mut self, key: K, value: V) -> Option<V>
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>
sourcefn for_each_value<F>(&self, f: F)where
F: FnMut(&V),
fn for_each_value<F>(&self, f: F)where
F: FnMut(&V),
Call the given closure for each key and value combination that is present in storage.