Struct array_map::ArrayMap[][src]

#[must_use]
pub struct ArrayMap<K, V, const N: usize> { /* fields omitted */ }
Expand description

A Map backed by an array. The keys must be known statically.

This map is O(1) for all operations. All members must be initialized at creation time so there is no option to insert or remove items from the map. Because of this it can be indexed into using the key type.

Implementations

impl<K: Indexable, V: Clone, const N: usize> ArrayMap<K, V, N>[src]

pub fn from_value(v: V) -> Self[src]

Returns a new ArrayMap where all the values are initialized to the same value

impl<K: Indexable, V, const N: usize> ArrayMap<K, V, N>[src]

pub fn from_closure(f: impl FnMut(&K) -> V) -> Self[src]

Returns a new ArrayMap where all the values are initialized to the same value

Panics

Panics if K::iter() returns anything other than N items or if K::index() returns a value >= N

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

Returns an iterator over all the items in the map. Note that the keys are owned.

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

Returns a mutable iterator over all the items in the map

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

Returns an iterator over all the keys in the map. Note that the keys are owned.

impl<K, V, const N: usize> ArrayMap<K, V, N>[src]

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

Returns an iterator over all the values in the map

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

Returns a mutable iterator over all the values in the map

Trait Implementations

impl<K, V, const N: usize> AsMut<[V; N]> for ArrayMap<K, V, N>[src]

fn as_mut(&mut self) -> &mut [V; N][src]

Performs the conversion.

impl<K, V, const N: usize> AsRef<[V; N]> for ArrayMap<K, V, N>[src]

fn as_ref(&self) -> &[V; N][src]

Performs the conversion.

impl<K, V: Clone, const N: usize> Clone for ArrayMap<K, V, N>[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<K: Debug + Indexable, V: Debug, const N: usize> Debug for ArrayMap<K, V, N>[src]

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

Formats the value using the given formatter. Read more

impl<K: Indexable, V: Default, const N: usize> Default for ArrayMap<K, V, N>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl<'de, K: Deserialize<'de> + Indexable, V: Deserialize<'de>, const N: usize> Deserialize<'de> for ArrayMap<K, V, N>[src]

fn deserialize<D>(
    deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
    D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<K: Indexable, const M: usize, const S: usize> From<&'_ ArrayMap<K, AtomicBool, M>> for ArraySet<K, S>[src]

fn from(m: &ArrayMap<K, AtomicBool, M>) -> Self[src]

Performs the conversion.

impl<K: Indexable, const M: usize, const S: usize> From<ArrayMap<K, bool, M>> for ArraySet<K, S>[src]

fn from(m: ArrayMap<K, bool, M>) -> Self[src]

Performs the conversion.

impl<K: Indexable, const M: usize, const S: usize> From<ArraySet<K, S>> for ArrayMap<K, bool, M>[src]

fn from(s: ArraySet<K, S>) -> Self[src]

Performs the conversion.

impl<K: Indexable, const M: usize, const S: usize> From<ArraySet<K, S>> for ArrayMap<K, AtomicBool, M>[src]

fn from(s: ArraySet<K, S>) -> Self[src]

Performs the conversion.

impl<K: Indexable, V, const N: usize> FromIterator<(K, V)> for ArrayMap<K, Option<V>, N>[src]

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self[src]

Creates a value from an iterator. Read more

impl<K: Indexable, V, const N: usize> Index<K> for ArrayMap<K, V, N>[src]

type Output = V

The returned type after indexing.

fn index(&self, index: K) -> &Self::Output[src]

Performs the indexing (container[index]) operation. Read more

impl<K: Indexable, V, const N: usize> IndexMut<K> for ArrayMap<K, V, N>[src]

fn index_mut(&mut self, index: K) -> &mut Self::Output[src]

Performs the mutable indexing (container[index]) operation. Read more

impl<K, V: PartialEq, const N: usize> PartialEq<ArrayMap<K, V, N>> for ArrayMap<K, V, N>[src]

fn eq(&self, other: &Self) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<K: Serialize + Indexable, V: Serialize, const N: usize> Serialize for ArrayMap<K, V, N>[src]

fn serialize<S>(
    &self,
    serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl<K, V: Copy, const N: usize> Copy for ArrayMap<K, V, N>[src]

impl<K, V: Eq, const N: usize> Eq for ArrayMap<K, V, N>[src]

Auto Trait Implementations

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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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

Performs the conversion.

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.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]