pub trait Storage<K, V>: Default {
type Iter<'this>: Clone + Iterator<Item = (K, &'this V)>
where
Self: 'this,
V: 'this;
type IterMut<'this>: Iterator<Item = (K, &'this mut V)>
where
Self: 'this,
V: 'this;
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(&self) -> Self::Iter<'_>;
fn iter_mut(&mut self) -> Self::IterMut<'_>;
}
Expand description
The trait defining how storage works.
Type Arguments
K
is the key being stored.V
is the value being stored.
Required Associated Types
sourcetype Iter<'this>: Clone + Iterator<Item = (K, &'this V)>
where
Self: 'this,
V: 'this
type Iter<'this>: Clone + Iterator<Item = (K, &'this V)>
where
Self: 'this,
V: 'this
Immutable iterator over storage. Uses raw pointers (unsafe) since we don’t have GATs.
sourcetype IterMut<'this>: Iterator<Item = (K, &'this mut V)>
where
Self: 'this,
V: 'this
type IterMut<'this>: Iterator<Item = (K, &'this mut V)>
where
Self: 'this,
V: 'this
Mutable iterator over storage. Uses raw pointers (unsafe) since we don’t have GATs.
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
.
sourcefn iter_mut(&mut self) -> Self::IterMut<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
This is the storage abstraction for Map::iter_mut
.