[][src]Struct storagevec::smap::StorageMap

#[repr(transparent)]pub struct StorageMap<K: Eq + Ord + Hash, V, const N: usize>(_);

A map object that with either use the tinymap TinyMap or the hashbrown HashMap as a backing implementation. It will use the alloc feature to control this.

Implementations

impl<K: Eq + Ord + Hash, V, const N: usize> StorageMap<K, V, N>[src]

#[must_use]pub fn new() -> Self[src]

Create a new, empty StorageMap.

#[must_use]pub fn len(&self) -> usize[src]

Get the length of this storage map.

#[must_use]pub fn is_empty(&self) -> bool[src]

Tell whether or not the storage map is empty.

#[must_use]pub fn get(&self, key: &K) -> Option<&V>[src]

Get an element from this map by its key.

#[must_use]pub fn get_mut(&mut self, key: &K) -> Option<&mut V>[src]

Get a mutable reference to an element by its key.

pub fn try_insert(&mut self, key: K, value: V) -> Result<Option<V>, (K, V)>[src]

Insert a new element into this map. If the key already exists in the map, it returns the value previously held in that slot. Otherwise, it will return None.

Errors

It will return back the key-value pair if the insertion cannot be accomplished due to capacity overflow.

pub fn insert(&mut self, key: K, value: V) -> Option<V>[src]

Insert a new element into this map.

pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)>[src]

Remove a key/value entry from this map.

pub fn remove(&mut self, key: &K) -> Option<V>[src]

Remove a value from this map.

pub fn contains_key(&self, key: &K) -> bool[src]

Tell whether this map contains a certain key.

pub fn iter(&self) -> impl Iterator<Item = (&K, &V)>[src]

Get an iterator that iterates over the key-value pairs in arbitrary order.

pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)>[src]

Get an iterator that iterates over the key-value pairs in arbitary order, mutably.

pub fn keys(&self) -> impl Iterator<Item = &K>[src]

Get an iterator that iterates over the keys in arbitrary order.

pub fn values(&self) -> impl Iterator<Item = &V>[src]

Get an iterator that iterates over the values in arbitrary order.

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>[src]

Get an iterator that iterates over the values in arbitrary order, mutably.

Trait Implementations

impl<K: Ord + Eq + Hash + Clone, V: Clone, const N: usize> Clone for StorageMap<K, V, N>[src]

impl<K: Ord + Eq + Hash + Debug, V: Debug, const N: usize> Debug for StorageMap<K, V, N>[src]

impl<K: Ord + Eq + Hash, V, const N: usize> Default for StorageMap<K, V, N>[src]

impl<K: Ord + Eq + Hash, V, const N: usize> Extend<(K, V)> for StorageMap<K, V, N>[src]

impl<K: Ord + Eq + Hash, V, const N: usize> FromIterator<(K, V)> for StorageMap<K, V, N>[src]

impl<K: Ord + Eq + Hash, V, const N: usize> IntoIterator for StorageMap<K, V, N>[src]

type Item = (K, V)

The type of the elements being iterated over.

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<K, V, const N: usize> Send for StorageMap<K, V, N> where
    K: Send,
    V: Send
[src]

impl<K, V, const N: usize> Sync for StorageMap<K, V, N> where
    K: Sync,
    V: Sync
[src]

impl<K, V, const N: usize> Unpin for StorageMap<K, V, N> where
    K: Unpin,
    V: Unpin
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.