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]
impl<A: ?Sized + UncheckedAnyExt> RawMap<A>pub fn new() -> RawMap<A>[src]
pub fn new() -> RawMap<A>Create an empty collection.
pub fn with_capacity(capacity: usize) -> RawMap<A>[src]
pub fn with_capacity(capacity: usize) -> RawMap<A>Creates an empty collection with the given initial capacity.
pub fn capacity(&self) -> usize[src]
pub fn capacity(&self) -> usizeReturns the number of elements the collection can hold without reallocating.
pub fn reserve(&mut self, additional: usize)[src]
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.
pub fn shrink_to_fit(&mut self)[src]
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.
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeReturns the number of items in the collection.
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolReturns true if there are no items in the collection.
pub fn clear(&mut self)[src]
pub fn clear(&mut self)Removes all items from the collection. Keeps the allocated memory for reuse.
impl<A: ?Sized + UncheckedAnyExt> RawMap<A>[src]
impl<A: ?Sized + UncheckedAnyExt> RawMap<A>ⓘImportant traits for Iter<'a, A>pub fn iter(&self) -> Iter<A>[src]
pub fn iter(&self) -> Iter<A>An iterator visiting all entries in arbitrary order.
Iterator element type is &Any.
ⓘImportant traits for IterMut<'a, A>pub fn iter_mut(&mut self) -> IterMut<A>[src]
pub fn iter_mut(&mut self) -> IterMut<A>An iterator visiting all entries in arbitrary order.
Iterator element type is &mut Any.
ⓘImportant traits for Drain<'a, A>pub fn drain(&mut self) -> Drain<A>[src]
pub fn drain(&mut self) -> Drain<A>Clears the map, returning all items as an iterator.
Iterator element type is Box<Any>.
Keeps the allocated memory for reuse.
pub fn entry(&mut self, key: TypeId) -> Entry<A>[src]
pub fn entry(&mut self, key: TypeId) -> Entry<A>Gets the entry for the given type in the collection for in-place manipulation.
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&A> where
TypeId: Borrow<Q>,
Q: Hash + Eq, [src]
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&A> where
TypeId: Borrow<Q>,
Q: Hash + Eq, 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.
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool where
TypeId: Borrow<Q>,
Q: Hash + Eq, [src]
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool where
TypeId: Borrow<Q>,
Q: Hash + Eq, 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.
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut A> where
TypeId: Borrow<Q>,
Q: Hash + Eq, [src]
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut A> where
TypeId: Borrow<Q>,
Q: Hash + Eq, 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.
pub unsafe fn insert(&mut self, key: TypeId, value: Box<A>) -> Option<Box<A>>[src]
pub unsafe fn insert(&mut self, key: TypeId, value: Box<A>) -> Option<Box<A>>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.
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<Box<A>> where
TypeId: Borrow<Q>,
Q: Hash + Eq, [src]
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<Box<A>> where
TypeId: Borrow<Q>,
Q: Hash + Eq, 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]
impl<A: Debug + ?Sized + UncheckedAnyExt> Debug for RawMap<A>fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
fn fmt(&self, __arg_0: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<A: ?Sized + UncheckedAnyExt> Clone for RawMap<A> where
Box<A>: Clone, [src]
impl<A: ?Sized + UncheckedAnyExt> Clone for RawMap<A> where
Box<A>: Clone, fn clone(&self) -> RawMap<A>[src]
fn clone(&self) -> RawMap<A>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<A: ?Sized + UncheckedAnyExt> Default for RawMap<A>[src]
impl<A: ?Sized + UncheckedAnyExt> Default for RawMap<A>impl<A: ?Sized + UncheckedAnyExt, Q> Index<Q> for RawMap<A> where
TypeId: Borrow<Q>,
Q: Eq + Hash, [src]
impl<A: ?Sized + UncheckedAnyExt, Q> Index<Q> for RawMap<A> where
TypeId: Borrow<Q>,
Q: Eq + Hash, type Output = A
The returned type after indexing.
fn index(&self, index: Q) -> &A[src]
fn index(&self, index: Q) -> &APerforms the indexing (container[index]) operation.
impl<A: ?Sized + UncheckedAnyExt, Q> IndexMut<Q> for RawMap<A> where
TypeId: Borrow<Q>,
Q: Eq + Hash, [src]
impl<A: ?Sized + UncheckedAnyExt, Q> IndexMut<Q> for RawMap<A> where
TypeId: Borrow<Q>,
Q: Eq + Hash, fn index_mut(&mut self, index: Q) -> &mut A[src]
fn index_mut(&mut self, index: Q) -> &mut APerforms the mutable indexing (container[index]) operation.
impl<A: ?Sized + UncheckedAnyExt> IntoIterator for RawMap<A>[src]
impl<A: ?Sized + UncheckedAnyExt> IntoIterator for RawMap<A>type Item = Box<A>
The type of the elements being iterated over.
type IntoIter = IntoIter<A>
Which kind of iterator are we turning this into?
ⓘImportant traits for IntoIter<A>fn into_iter(self) -> IntoIter<A>[src]
fn into_iter(self) -> IntoIter<A>Creates an iterator from a value. Read more
impl<A: ?Sized + UncheckedAnyExt> AsRef<RawMap<A>> for Map<A>[src]
impl<A: ?Sized + UncheckedAnyExt> AsRef<RawMap<A>> for Map<A>impl<A: ?Sized + UncheckedAnyExt> AsMut<RawMap<A>> for Map<A>[src]
impl<A: ?Sized + UncheckedAnyExt> AsMut<RawMap<A>> for Map<A>impl<A: ?Sized + UncheckedAnyExt> Into<RawMap<A>> for Map<A>[src]
impl<A: ?Sized + UncheckedAnyExt> Into<RawMap<A>> for Map<A>