[−][src]Struct typemap::TypeMap
A map keyed by types.
Can contain one value of any type for each key type, as defined by the Assoc trait.
You usually do not need to worry about the A type parameter, but it
can be used to add bounds to the possible value types that can
be stored in this map. Usually, you are looking for ShareMap, which
is Send + Sync.
Methods
impl TypeMap[src]
impl<A: UnsafeAnyExt + ?Sized> TypeMap<A>[src]
pub fn custom() -> TypeMap<A>[src]
Create a new, empty TypeMap.
Can be used with any A parameter; new is specialized to get around
the required type annotations when using this function.
pub fn insert<K: Key>(&mut self, val: K::Value) -> Option<K::Value> where
K::Value: Any + Implements<A>, [src]
K::Value: Any + Implements<A>,
Insert a value into the map with a specified key type.
pub fn get<K: Key>(&self) -> Option<&K::Value> where
K::Value: Any + Implements<A>, [src]
K::Value: Any + Implements<A>,
Find a value in the map and get a reference to it.
pub fn get_mut<K: Key>(&mut self) -> Option<&mut K::Value> where
K::Value: Any + Implements<A>, [src]
K::Value: Any + Implements<A>,
Find a value in the map and get a mutable reference to it.
pub fn contains<K: Key>(&self) -> bool[src]
Check if a key has an associated value stored in the map.
pub fn remove<K: Key>(&mut self) -> Option<K::Value> where
K::Value: Any + Implements<A>, [src]
K::Value: Any + Implements<A>,
Remove a value from the map.
Returns true if a value was removed.
pub fn entry<'a, K: Key>(&'a mut self) -> Entry<'a, K, A> where
K::Value: Any + Implements<A>, [src]
K::Value: Any + Implements<A>,
Get the given key's corresponding entry in the map for in-place manipulation.
pub unsafe fn data(&self) -> &HashMap<TypeId, Box<A>>[src]
Read the underlying HashMap
pub unsafe fn data_mut(&mut self) -> &mut HashMap<TypeId, Box<A>>[src]
Get a mutable reference to the underlying HashMap
pub fn len(&self) -> usize[src]
Get the number of values stored in the map.
pub fn is_empty(&self) -> bool[src]
Return true if the map contains no values.
pub fn clear(&mut self)[src]
Remove all entries from the map.
Trait Implementations
impl<A: Default + ?Sized> Default for TypeMap<A> where
A: UnsafeAnyExt, [src]
A: UnsafeAnyExt,
impl<A: ?Sized> Clone for TypeMap<A> where
A: UnsafeAnyExt,
Box<A>: Clone, [src]
A: UnsafeAnyExt,
Box<A>: Clone,
fn clone(&self) -> TypeMap<A>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<A: Debug + ?Sized> Debug for TypeMap<A> where
A: UnsafeAnyExt, [src]
A: UnsafeAnyExt,
Auto Trait Implementations
impl<A: ?Sized> Send for TypeMap<A> where
A: Send,
A: Send,
impl<A: ?Sized> Sync for TypeMap<A> where
A: Sync,
A: Sync,
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> UnsafeAny for T where
T: Any, [src]
T: Any,