Struct iron::TypeMap
[−]
[src]
pub struct TypeMap<A = UnsafeAny + 'static> where
A: UnsafeAnyExt + ?Sized, { /* fields omitted */ }
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<UnsafeAny + 'static>
[src]
impl<A> TypeMap<A> where
A: UnsafeAnyExt + ?Sized,
[src]
A: UnsafeAnyExt + ?Sized,
fn custom() -> TypeMap<A>
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.
fn insert<K>(&mut self, val: <K as Key>::Value) -> Option<<K as Key>::Value> where
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
Insert a value into the map with a specified key type.
fn get<K>(&self) -> Option<&<K as Key>::Value> where
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
Find a value in the map and get a reference to it.
fn get_mut<K>(&mut self) -> Option<&mut <K as Key>::Value> where
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
Find a value in the map and get a mutable reference to it.
fn contains<K>(&self) -> bool where
K: Key,
K: Key,
Check if a key has an associated value stored in the map.
fn remove<K>(&mut self) -> Option<<K as Key>::Value> where
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
Remove a value from the map.
Returns true
if a value was removed.
fn entry<K>(&'a mut self) -> Entry<'a, K, A> where
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
K: Key,
<K as Key>::Value: Any,
<K as Key>::Value: Implements<A>,
Get the given key's corresponding entry in the map for in-place manipulation.
unsafe fn data(&self) -> &HashMap<TypeId, Box<A>, RandomState>
Read the underlying HashMap
unsafe fn data_mut(&mut self) -> &mut HashMap<TypeId, Box<A>, RandomState>
Get a mutable reference to the underlying HashMap
fn len(&self) -> usize
Get the number of values stored in the map.
fn is_empty(&self) -> bool
Return true if the map contains no values.
fn clear(&mut self)
Remove all entries from the map.
Trait Implementations
impl<A> Debug for TypeMap<A> where
A: Debug + UnsafeAnyExt + ?Sized,
[src]
A: Debug + UnsafeAnyExt + ?Sized,
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.
impl<A> Default for TypeMap<A> where
A: Default + UnsafeAnyExt + ?Sized,
[src]
A: Default + UnsafeAnyExt + ?Sized,
impl<A> Clone for TypeMap<A> where
A: UnsafeAnyExt + ?Sized,
Box<A>: Clone,
[src]
A: UnsafeAnyExt + ?Sized,
Box<A>: Clone,
fn clone(&self) -> TypeMap<A>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more