Struct linear_collections::ArrayMap
source · pub struct ArrayMap<K: Eq, V: Sized + PartialEq, const LENGTH: usize> { /* private fields */ }
Implementations§
source§impl<K: Eq, V: Sized + PartialEq, const LENGTH: usize> ArrayMap<K, V, LENGTH>
impl<K: Eq, V: Sized + PartialEq, const LENGTH: usize> ArrayMap<K, V, LENGTH>
sourcepub const unsafe fn new_unchecked(
array: [(K, V); LENGTH]
) -> ArrayMap<K, V, LENGTH>
pub const unsafe fn new_unchecked( array: [(K, V); LENGTH] ) -> ArrayMap<K, V, LENGTH>
Creates a new ArrayMap from the provided array: use this if you know for a fact that each key provided is unique.
Don’t be afraid by the unsafe marker: improper use of this method will NOT create memory unsafety, but will result in every identical key beyond the first never getting accessed as LinearMaps short circuit on the first matching key.
sourcepub fn merge_from_iter(&mut self, iter: impl Iterator<Item = (K, V)>)
pub fn merge_from_iter(&mut self, iter: impl Iterator<Item = (K, V)>)
Replaces a values all key value pairs matching an element from iter with that element from iter.
for example: [(A,1), (B, 2)].merge([(A,1), (B, 2’), (C, 2), (D, 3)].into_iter()) will yield a map: [(A, 1), (B, 2’)]
Trait Implementations§
source§impl<K: Clone + Eq, V: Clone + Sized + PartialEq, const LENGTH: usize> Clone for ArrayMap<K, V, LENGTH>
impl<K: Clone + Eq, V: Clone + Sized + PartialEq, const LENGTH: usize> Clone for ArrayMap<K, V, LENGTH>
source§impl<K: Eq, V: Sized + PartialEq, const LENGTH: usize> LinearMap<K, V> for ArrayMap<K, V, LENGTH>
impl<K: Eq, V: Sized + PartialEq, const LENGTH: usize> LinearMap<K, V> for ArrayMap<K, V, LENGTH>
type Backing = [(K, V); LENGTH]
source§fn into_inner(self) -> Self::Backing
fn into_inner(self) -> Self::Backing
Consumes self, returning the underlying store.
source§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
Returns true if this map contains the given key. False otherwise.
source§fn contains_value(&self, value: &V) -> bool
fn contains_value(&self, value: &V) -> bool
Returns true if this map contains a given value. False otherwise.
source§fn get<'a>(&'a self, key: &'a K) -> Option<&'a V>
fn get<'a>(&'a self, key: &'a K) -> Option<&'a V>
Gets a reference with the associated key. Will return None if that i
key is not in the map.
source§fn get_mut<'a>(&'a mut self, key: &'a K) -> Option<&'a mut V>
fn get_mut<'a>(&'a mut self, key: &'a K) -> Option<&'a mut V>
Gets a mutable reference with the associated key. Will return None if that
key is not in the map.
source§fn nth_value<'a>(&'a self, index: usize) -> Option<&'a V>where
K: 'a,
fn nth_value<'a>(&'a self, index: usize) -> Option<&'a V>where
K: 'a,
Gets a reference to the nth value in the map.
Will return None if index is out of bounds.
source§fn nth_value_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut V>where
K: 'a,
fn nth_value_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut V>where
K: 'a,
Gets a reference to the nth value in the map.
Will return None if index is out of bounds.
source§fn nth_key<'a>(&'a self, index: usize) -> Option<&'a K>where
V: 'a,
fn nth_key<'a>(&'a self, index: usize) -> Option<&'a K>where
V: 'a,
Gets a reference to the nth value in the map.
Will return None if index is out of bounds.
impl<K: Copy + Eq, V: Copy + Sized + PartialEq, const LENGTH: usize> Copy for ArrayMap<K, V, LENGTH>
Auto Trait Implementations§
impl<K, V, const LENGTH: usize> Freeze for ArrayMap<K, V, LENGTH>
impl<K, V, const LENGTH: usize> RefUnwindSafe for ArrayMap<K, V, LENGTH>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, const LENGTH: usize> Send for ArrayMap<K, V, LENGTH>
impl<K, V, const LENGTH: usize> Sync for ArrayMap<K, V, LENGTH>
impl<K, V, const LENGTH: usize> Unpin for ArrayMap<K, V, LENGTH>
impl<K, V, const LENGTH: usize> UnwindSafe for ArrayMap<K, V, LENGTH>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more