Struct anymap::raw::RawMap [] [src]

pub struct RawMap<A: ?Sized + UncheckedAnyExt = Any> { /* fields omitted */ }

The raw, underlying form of a Map.

At its essence, this is a wrapper around HashMap<TypeId, Box<Any>>, with the portions that would be memory-unsafe removed or marked unsafe. Normal people are expected to use the safe Map interface instead, but there is the occasional use for this such as iteration over the contents of an Map. However, because you will then be dealing with Any trait objects, it doesn’t tend to be so very useful. Still, if you need it, it’s here.

Methods

impl<A: ?Sized + UncheckedAnyExt> RawMap<A>
[src]

Create an empty collection.

Creates an empty collection with the given initial capacity.

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

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.

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.

Returns the number of items in the collection.

Returns true if there are no items in the collection.

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

impl<A: ?Sized + UncheckedAnyExt> RawMap<A>
[src]

An iterator visiting all entries in arbitrary order.

Iterator element type is &Any.

An iterator visiting all entries in arbitrary order.

Iterator element type is &mut Any.

Clears the map, returning all items as an iterator.

Iterator element type is Box<Any>.

Keeps the allocated memory for reuse.

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

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Returns a mutable reference to the value corresponding to the key.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Inserts a key-value pair from the map. If the key already had a value present in the map, that value is returned. Otherwise, None is returned.

It is the caller’s responsibility to ensure that the key corresponds with the type ID of the value. If they do not, memory safety may be violated.

Removes a key from the map, returning the value at the key if the key was previously in the map.

The key may be any borrowed form of the map's key type, but Hash and Eq on the borrowed form must match those for the key type.

Trait Implementations

impl<A: Debug + ?Sized + UncheckedAnyExt> Debug for RawMap<A>
[src]

Formats the value using the given formatter.

impl<A: ?Sized + UncheckedAnyExt> Clone for RawMap<A> where
    Box<A>: Clone
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<A: ?Sized + UncheckedAnyExt> Default for RawMap<A>
[src]

Returns the "default value" for a type. Read more

impl<A: ?Sized + UncheckedAnyExt, Q> Index<Q> for RawMap<A> where
    TypeId: Borrow<Q>,
    Q: Eq + Hash
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl<A: ?Sized + UncheckedAnyExt, Q> IndexMut<Q> for RawMap<A> where
    TypeId: Borrow<Q>,
    Q: Eq + Hash
[src]

The method for the mutable indexing (container[index]) operation

impl<A: ?Sized + UncheckedAnyExt> IntoIterator for RawMap<A>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more