pub struct Assoc<K: Key, V> { /* private fields */ }Expand description
Associates keys with values with minimal or no runtime overhead.
Implementations§
Source§impl<K: Key, V, const N: usize> Assoc<K, V>where
K::Impl: KeyImpl<Storage<V> = [V; N]>,
impl<K: Key, V, const N: usize> Assoc<K, V>where
K::Impl: KeyImpl<Storage<V> = [V; N]>,
pub const LEN: usize = N
pub const fn from_values(values: [V; N]) -> Self
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
Sourcepub fn get(&self, key: K) -> &V
pub fn get(&self, key: K) -> &V
Returns a reference to the value associated with the given key.
Sourcepub const fn const_get(&self, key: K) -> &V
pub const fn const_get(&self, key: K) -> &V
Returns a reference to the value associated with the given key.
This version does bounds-checking therefore can be used in const
contexts, unlike get.
Sourcepub fn get_mut(&mut self, key: K) -> &mut V
pub fn get_mut(&mut self, key: K) -> &mut V
Returns a mutable reference to the value associated with the given key.
Sourcepub const fn const_get_mut(&mut self, key: K) -> &mut V
pub const fn const_get_mut(&mut self, key: K) -> &mut V
Returns a mutable reference to the value associated with the given key.
This version does bounds-checking, therefore can be used in const
contexts, unlike get.
Sourcepub fn into_values(self) -> impl Iterator<Item = V>
pub fn into_values(self) -> impl Iterator<Item = V>
Takes self by value and returns an iterator over all the values
stored in this map.
Sourcepub fn values(&self) -> impl Iterator<Item = &V>
pub fn values(&self) -> impl Iterator<Item = &V>
Returns an iterator over shared references to all values stored in this map in arbitrary order.
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>
Returns an iterator over mutable references to all values stored in this map in arbitrary order.
Source§impl<K: Key, V, const N: usize> Assoc<K, MaybeUninit<V>>where
K::Impl: KeyImpl<Storage<V> = [V; N]> + KeyImpl<Storage<MaybeUninit<V>> = [MaybeUninit<V>; N]>,
impl<K: Key, V, const N: usize> Assoc<K, MaybeUninit<V>>where
K::Impl: KeyImpl<Storage<V> = [V; N]> + KeyImpl<Storage<MaybeUninit<V>> = [MaybeUninit<V>; N]>,
pub const fn new_uninit() -> Self
Sourcepub const unsafe fn assume_init(self) -> Assoc<K, V>
pub const unsafe fn assume_init(self) -> Assoc<K, V>
Interprets this map as fully initialized, meaning that all its values have been given a concrete value.
§Safety
The caller must ensure that the map has actually been fully
initialized, meaning that all values have been given an initialized
value such that calling MaybeUninit::assume_init on them would be
safe.