mod boolean;
pub(crate) use self::boolean::BooleanMapStorage;
#[cfg(feature = "hashbrown")]
mod hashbrown;
#[cfg(feature = "hashbrown")]
pub(crate) use self::hashbrown::HashbrownMapStorage;
mod option;
pub(crate) use self::option::OptionMapStorage;
mod singleton;
pub(crate) use self::singleton::SingletonMapStorage;
use crate::map::Entry;
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;
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>;
}
pub trait OccupiedEntry<'a, K, V> {
fn key(&self) -> K;
fn get(&self) -> &V;
fn get_mut(&mut self) -> &mut V;
fn into_mut(self) -> &'a mut V;
fn insert(&mut self, value: V) -> V;
fn remove(self) -> V;
}
pub trait VacantEntry<'a, K, V> {
fn key(&self) -> K;
fn insert(self, value: V) -> &'a mut V;
}