pub trait Storage<K: 'static, V: 'static>: 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 clear(&mut self);
fn iter<'a, F>(&'a self, f: F)
where
F: FnMut((&'a K, &'a V));
fn iter_mut<'a, F>(&'a mut self, f: F)
where
F: FnMut((&'a K, &'a mut 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
sourcefn insert(&mut self, key: K, value: V) -> Option<V>
fn insert(&mut self, key: K, value: V) -> Option<V>
This is the storage abstraction for Map::insert
.
sourcefn get_mut(&mut self, key: &K) -> Option<&mut V>
fn get_mut(&mut self, key: &K) -> Option<&mut V>
This is the storage abstraction for Map::get_mut
.
sourcefn remove(&mut self, key: &K) -> Option<V>
fn remove(&mut self, key: &K) -> Option<V>
This is the storage abstraction for Map::remove
.
sourcefn clear(&mut self)
fn clear(&mut self)
This is the storage abstraction for Map::clear
.