pub trait MapStorage<K, V>: Sized {
type Iter<'this>: Iterator<Item = (K, &'this V)>
where Self: 'this,
V: 'this;
type Keys<'this>: Iterator<Item = K>
where Self: 'this;
type Values<'this>: Iterator<Item = &'this V>
where Self: 'this,
V: 'this;
type IterMut<'this>: Iterator<Item = (K, &'this mut V)>
where Self: 'this,
V: 'this;
type ValuesMut<'this>: Iterator<Item = &'this mut V>
where Self: 'this,
V: 'this;
type IntoIter: Iterator<Item = (K, V)>;
type Occupied<'this>: OccupiedEntry<'this, K, V>
where Self: 'this;
type Vacant<'this>: VacantEntry<'this, K, V>
where Self: 'this;
Show 17 methods
// Required methods
fn empty() -> Self;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn insert(&mut self, key: K, value: V) -> Option<V>;
fn contains_key(&self, key: K) -> bool;
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 retain<F>(&mut self, f: F)
where F: FnMut(K, &mut V) -> bool;
fn clear(&mut self);
fn iter(&self) -> Self::Iter<'_>;
fn keys(&self) -> Self::Keys<'_>;
fn values(&self) -> Self::Values<'_>;
fn iter_mut(&mut self) -> Self::IterMut<'_>;
fn values_mut(&mut self) -> Self::ValuesMut<'_>;
fn into_iter(self) -> Self::IntoIter;
fn entry(&mut self, key: K) -> Entry<'_, Self, K, V>;
}
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>: Iterator<Item = (K, &'this V)>
where
Self: 'this,
V: 'this
type Iter<'this>: Iterator<Item = (K, &'this V)> where Self: 'this, V: 'this
Immutable iterator over storage.
Sourcetype Keys<'this>: Iterator<Item = K>
where
Self: 'this
type Keys<'this>: Iterator<Item = K> where Self: 'this
Immutable iterator over keys in storage.
Sourcetype Values<'this>: Iterator<Item = &'this V>
where
Self: 'this,
V: 'this
type Values<'this>: Iterator<Item = &'this V> where Self: 'this, V: 'this
Immutable iterator over values in storage.
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.
Sourcetype ValuesMut<'this>: Iterator<Item = &'this mut V>
where
Self: 'this,
V: 'this
type ValuesMut<'this>: Iterator<Item = &'this mut V> where Self: 'this, V: 'this
Mutable iterator over values in storage.
Sourcetype Occupied<'this>: OccupiedEntry<'this, K, V>
where
Self: 'this
type Occupied<'this>: OccupiedEntry<'this, K, V> where Self: 'this
An occupied entry.
Sourcetype Vacant<'this>: VacantEntry<'this, K, V>
where
Self: 'this
type Vacant<'this>: VacantEntry<'this, K, V> where Self: 'this
A vacant entry.
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 contains_key(&self, key: K) -> bool
fn contains_key(&self, key: K) -> bool
This is the storage abstraction for Map::contains_key
.
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 retain<F>(&mut self, f: F)
fn retain<F>(&mut self, f: F)
This is the storage abstraction for Map::retain
.
Sourcefn clear(&mut self)
fn clear(&mut self)
This is the storage abstraction for Map::clear
.
Sourcefn values(&self) -> Self::Values<'_>
fn values(&self) -> Self::Values<'_>
This is the storage abstraction for Map::values
.
Sourcefn iter_mut(&mut self) -> Self::IterMut<'_>
fn iter_mut(&mut self) -> Self::IterMut<'_>
This is the storage abstraction for Map::iter_mut
.
Sourcefn values_mut(&mut self) -> Self::ValuesMut<'_>
fn values_mut(&mut self) -> Self::ValuesMut<'_>
This is the storage abstraction for Map::values_mut
.
Sourcefn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
This is the storage abstraction for Map::into_iter
.
Sourcefn entry(&mut self, key: K) -> Entry<'_, Self, K, V>
fn entry(&mut self, key: K) -> Entry<'_, Self, K, V>
This is the storage abstraction for Map::entry
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.