Trait TypeMap

Source
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§

Source

type Key: MapKey<Map = Self>

Required Methods§

Source

fn new() -> Self

Creates a new typemap

Source

fn insert<T: TypedKeyTrait<Self::Key>>(&mut self, value: T::Value)

Inserts a value into the typemap with the given key

Source

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

Source

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

Source

fn remove<T: TypedKeyTrait<Self::Key>>(&mut self) -> Option<T::Value>

Removes a value from the map for the given key

Source

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.

Implementors§

Source§

impl TypeMap for AnyTypeMap

Source§

type Key = AnyTypeMapKey

Source§

impl TypeMap for CloneSendSyncTypeMap

Source§

type Key = CloneSendSyncTypeMapKey

Source§

impl TypeMap for CloneTypeMap

Source§

type Key = CloneTypeMapKey

Source§

impl TypeMap for PartialEqTypeMap

Source§

type Key = PartialEqTypeMapKey

Source§

impl TypeMap for SendSyncTypeMap

Source§

type Key = SendSyncTypeMapKey