Assoc

Struct Assoc 

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

Source

pub const LEN: usize = N

Source

pub const fn from_values(values: [V; N]) -> Self

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub fn get(&self, key: K) -> &V

Returns a reference to the value associated with the given key.

Source

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.

Source

pub fn get_mut(&mut self, key: K) -> &mut V

Returns a mutable reference to the value associated with the given key.

Source

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.

Source

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.

Source

pub fn values(&self) -> impl Iterator<Item = &V>

Returns an iterator over shared references to all values stored in this map in arbitrary order.

Source

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

Source

pub const fn new_uninit() -> Self

Source

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.

Trait Implementations§

Source§

impl<K: Key, V: ConstDefault> ConstDefault for Assoc<K, V>
where <K::Impl as KeyImpl>::Storage<V>: ConstDefault,

Source§

const DEFAULT: Self

The constant default value.
Source§

impl<K: Key, V: ConstDefault> Default for Assoc<K, V>
where <K::Impl as KeyImpl>::Storage<V>: Default,

Source§

fn default() -> Self

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

impl<K: Key, V, const N: usize> Index<K> for Assoc<K, V>
where K::Impl: KeyImpl<Storage<V> = [V; N]>,

Source§

type Output = V

The returned type after indexing.
Source§

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

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

impl<K: Key, V, const N: usize> IndexMut<K> for Assoc<K, V>
where K::Impl: KeyImpl<Storage<V> = [V; N]>,

Source§

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

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

Auto Trait Implementations§

§

impl<K, V> Freeze for Assoc<K, V>
where <<K as Key>::Impl as KeyImpl>::Storage<V>: Freeze,

§

impl<K, V> RefUnwindSafe for Assoc<K, V>
where <<K as Key>::Impl as KeyImpl>::Storage<V>: RefUnwindSafe,

§

impl<K, V> Send for Assoc<K, V>
where <<K as Key>::Impl as KeyImpl>::Storage<V>: Send,

§

impl<K, V> Sync for Assoc<K, V>
where <<K as Key>::Impl as KeyImpl>::Storage<V>: Sync,

§

impl<K, V> Unpin for Assoc<K, V>
where <<K as Key>::Impl as KeyImpl>::Storage<V>: Unpin,

§

impl<K, V> UnwindSafe for Assoc<K, V>
where <<K as Key>::Impl as KeyImpl>::Storage<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, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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, 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.