pub struct Map<A: ?Sized + Downcast = dyn Any> { /* private fields */ }
Expand description
A collection containing zero or one values for any given type and allowing convenient, type-safe access to those values.
The type parameter A
allows you to use a different value type; normally you will want
it to be core::any::Any
(also known as std::any::Any
), but there are other choices:
- You can add on
+ Send
or+ Send + Sync
(e.g.Map<dyn Any + Send>
) to add those auto traits.
Cumulatively, there are thus six forms of map:
Map<dyn core::any::Any>
, also spelledAnyMap
for convenience.Map<dyn core::any::Any + Send>
Map<dyn core::any::Any + Send + Sync>
§Example
(Here using the AnyMap
convenience alias; the first line could use
anymap::Map::<core::any::Any>::new()
instead if desired.)
let mut data = anymap::AnyMap::new();
assert_eq!(data.get(), None::<&i32>);
Values containing non-static references are not permitted.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for Map<A>where
A: ?Sized,
impl<A> RefUnwindSafe for Map<A>where
A: RefUnwindSafe + ?Sized,
impl<A> Send for Map<A>
impl<A> Sync for Map<A>
impl<A> Unpin for Map<A>where
A: ?Sized,
impl<A> UnwindSafe for Map<A>where
A: UnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more