anymap2

Type Alias AnyMap

Source
pub type AnyMap = Map<dyn Any>;
Expand description

The most common type of Map: just using Any.

Why is this a separate type alias rather than a default value for Map<A>? Map::new() doesn’t seem to be happy to infer that it should go with the default value. It’s a bit sad, really. Ah well, I guess this approach will do.

Aliased Type§

struct AnyMap { /* private fields */ }

Implementations

Source§

impl<A: ?Sized + UncheckedAnyExt> Map<A>

Source

pub fn new() -> Map<A>

Create an empty collection.

Source

pub fn with_capacity(capacity: usize) -> Map<A>

Creates an empty collection with the given initial capacity.

Source

pub fn capacity(&self) -> usize

Returns the number of elements the collection can hold without reallocating.

Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the collection. The collection may reserve more space to avoid frequent reallocations.

§Panics

Panics if the new allocation size overflows usize.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the collection as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.

Source

pub fn len(&self) -> usize

Returns the number of items in the collection.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no items in the collection.

Source

pub fn clear(&mut self)

Removes all items from the collection. Keeps the allocated memory for reuse.

Source§

impl<A: ?Sized + UncheckedAnyExt> Map<A>

Source

pub fn get<T: IntoBox<A>>(&self) -> Option<&T>

Returns a reference to the value stored in the collection for the type T, if it exists.

Source

pub fn get_mut<T: IntoBox<A>>(&mut self) -> Option<&mut T>

Returns a mutable reference to the value stored in the collection for the type T, if it exists.

Source

pub fn insert<T: IntoBox<A>>(&mut self, value: T) -> Option<T>

Sets the value stored in the collection for the type T. If the collection already had a value of type T, that value is returned. Otherwise, None is returned.

Source

pub fn remove<T: IntoBox<A>>(&mut self) -> Option<T>

Removes the T value from the collection, returning it if there was one or None if there was not.

Source

pub fn contains<T: IntoBox<A>>(&self) -> bool

Returns true if the collection contains a value of type T.

Source

pub fn entry<T: IntoBox<A>>(&mut self) -> Entry<'_, A, T>

Gets the entry for the given type in the collection for in-place manipulation

Trait Implementations

Source§

impl<A: ?Sized + UncheckedAnyExt> AsMut<RawMap<A>> for Map<A>

Source§

fn as_mut(&mut self) -> &mut RawMap<A>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<A: ?Sized + UncheckedAnyExt> AsRef<RawMap<A>> for Map<A>

Source§

fn as_ref(&self) -> &RawMap<A>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<A: ?Sized + UncheckedAnyExt> Clone for Map<A>
where Box<A>: Clone,

Source§

fn clone(&self) -> Map<A>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug + ?Sized + UncheckedAnyExt> Debug for Map<A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: ?Sized + UncheckedAnyExt> Default for Map<A>

Source§

fn default() -> Map<A>

Returns the “default value” for a type. Read more