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>

source

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.

source

pub const fn len(&self) -> usize

Returns the number of items in this ArrayMap

source

pub const fn is_empty(&self) -> bool

Returns true if the store is empty, false otherwise.

source

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>

source§

fn clone(&self) -> ArrayMap<K, V, LENGTH>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<K: Eq, V: Sized + PartialEq, const LENGTH: usize> LinearMap<K, V> for ArrayMap<K, V, LENGTH>

§

type Backing = [(K, V); LENGTH]

source§

fn as_slice(&self) -> &[(K, V)]

The keys and values of the map.
source§

fn into_inner(self) -> Self::Backing

Consumes self, returning the underlying store.
source§

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

Returns true if this map contains a given value. False otherwise.
source§

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>

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,

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,

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,

Gets a reference to the nth value in the map. Will return None if index is out of bounds.
source§

fn nth_key_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut K>
where V: 'a,

Gets a reference to the nth key in the map. Will return None if index is out of bounds.
source§

fn replace(&mut self, key: &K, value: V)

Searches for a key == key in the map. If it is present replaces its value with “value”. If not, it does nothing.
source§

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>
where K: Freeze, V: Freeze,

§

impl<K, V, const LENGTH: usize> RefUnwindSafe for ArrayMap<K, V, LENGTH>

§

impl<K, V, const LENGTH: usize> Send for ArrayMap<K, V, LENGTH>
where K: Send, V: Send,

§

impl<K, V, const LENGTH: usize> Sync for ArrayMap<K, V, LENGTH>
where K: Sync, V: Sync,

§

impl<K, V, const LENGTH: usize> Unpin for ArrayMap<K, V, LENGTH>
where K: Unpin, V: Unpin,

§

impl<K, V, const LENGTH: usize> UnwindSafe for ArrayMap<K, V, LENGTH>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.