use crate::containers::Container;
pub trait Entry<K>: Container {
type Entry<'a>
where
Self: 'a,
K: 'a;
fn entry(&mut self, key: K) -> Self::Entry<'_>;
}
pub trait CombinedEntry<'a, K, V>: Sized {
type OccupiedEntry: OccupiedEntry<'a, K, V>;
fn key(&self) -> &K;
fn or_insert(self, default: V) -> &'a mut V;
fn or_insert_with<F>(self, default: F) -> &'a mut V
where
F: FnOnce() -> V;
fn or_insert_with_key<F>(self, default: F) -> &'a mut V
where
F: FnOnce(&K) -> V;
fn and_modify<F>(self, f: F) -> Self
where
F: FnOnce(&mut V);
fn insert_entry(self, value: V) -> Self::OccupiedEntry;
fn or_default(self) -> &'a mut V
where
V: Default;
}
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;
fn remove_entry(self) -> (K, V);
}
pub trait VacantEntry<'a, K, V> {
type OccupiedEntry: OccupiedEntry<'a, K, V>;
fn key(&self) -> &K;
fn into_key(self) -> K;
fn insert(self, value: V) -> &'a mut V;
fn insert_entry(self, value: V) -> Self::OccupiedEntry;
}