use core::borrow::Borrow;
pub trait Map {
type Key;
type Value;
}
pub trait MapGet<K: ?Sized>: Map
where
Self::Key: Borrow<K>,
{
fn get(&self, key: &K) -> Option<&Self::Value>;
#[inline]
fn contains_key(&self, key: &K) -> bool {
self.get(key).is_some()
}
}
pub trait MapMut<K: ?Sized>: MapGet<K>
where
Self::Key: Borrow<K>,
{
fn get_mut(&mut self, key: &K) -> Option<&mut Self::Value>;
fn remove(&mut self, key: &K) -> Option<Self::Value>;
}
pub trait MapInsert: Map {
fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value>;
}