ArrayMap

Struct 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 from_array_unchecked( array: [(K, V); LENGTH], ) -> ArrayMap<K, V, LENGTH>

Please only use this method to create map literals if the “macros” feature is unavailable to you “macros” provides safe, checked alternatives to initialize linear maps with compile time checking of the invariants of each type.

Creates a new ArrayMap from the supplied array.

SAFETY: improper use of this method - initializing with duplicate keys -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 elements in the ArrayMap

Source

pub const fn is_empty(&self) -> bool

Returns true if the store is empty, false otherwise.

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 duplicate 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: Debug + Eq, V: Debug + Sized + PartialEq, const LENGTH: usize> Debug for ArrayMap<K, V, LENGTH>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

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

Source§

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§

fn merge_from_iter<'a>(&'a mut self, iter: impl Iterator<Item = &'a (K, V)>)
where K: 'a, V: 'a + Clone,

For every key in iter which matches a key in self, this method replaces the value from iter in self, “merging” the iterator and the map. Read more
Source§

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

Source§

fn cmp(&self, other: &ArrayMap<K, V, LENGTH>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

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

Source§

fn eq(&self, other: &ArrayMap<K, V, LENGTH>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Source§

fn partial_cmp(&self, other: &ArrayMap<K, V, LENGTH>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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

Source§

impl<K: Eq, V: Sized + PartialEq, const LENGTH: usize> StructuralPartialEq 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.