pub trait TypeMap {
type Key: MapKey<Map = Self>;
// Required methods
fn new() -> Self;
fn insert<T: TypedKeyTrait<Self::Key>>(&mut self, value: T::Value);
fn get<T: TypedKeyTrait<Self::Key>>(&self) -> Option<&T::Value>;
fn get_mut<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<&mut T::Value>;
fn remove<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<T::Value>;
fn contains_key<T: TypedKeyTrait<Self::Key>>(&self) -> bool;
}
Expand description
A trait implemented by all typemaps that provides all basic typemap functions
Required Associated Types§
Required Methods§
Sourcefn insert<T: TypedKeyTrait<Self::Key>>(&mut self, value: T::Value)
fn insert<T: TypedKeyTrait<Self::Key>>(&mut self, value: T::Value)
Inserts a value into the typemap with the given key
Sourcefn get<T: TypedKeyTrait<Self::Key>>(&self) -> Option<&T::Value>
fn get<T: TypedKeyTrait<Self::Key>>(&self) -> Option<&T::Value>
Returns a reference to a value from the type map with the given provided key
Sourcefn get_mut<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<&mut T::Value>
fn get_mut<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<&mut T::Value>
Returns a mutable reference to a value from the type map with the given provided key
Sourcefn remove<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<T::Value>
fn remove<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<T::Value>
Removes a value from the map for the given key
Sourcefn contains_key<T: TypedKeyTrait<Self::Key>>(&self) -> bool
fn contains_key<T: TypedKeyTrait<Self::Key>>(&self) -> bool
Returns if the map contains a given key
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.