Struct enumoid::EnumOptionMap

source ·
pub struct EnumOptionMap<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait = u8> { /* private fields */ }
Expand description

A partial map from enumoid T to values V.

The optional type parameter BitsetWord is passed on to an embedded EnumSet which is used to store the validity bitmap.

Implementations§

source§

impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> EnumOptionMap<T, V, BitsetWord>

source

pub fn new() -> Self

Creates a new empty map.

source

pub fn get_by_index(&self, index: EnumIndex<T>) -> Option<&V>

Returns a reference to the value associated with a given index, or None if the index has no value in the map.

source

pub fn get(&self, key: T) -> Option<&V>

Returns a reference to the value associated with a given key, or None if the key has no value in the map.

source

pub fn get_by_index_mut(&mut self, index: EnumIndex<T>) -> Option<&mut V>

Returns a mutable reference to the value associated with a given index, or None if the index has no value in the map.

source

pub fn get_mut(&mut self, key: T) -> Option<&mut V>

Returns a mutable reference to the value associated with a given key, or None if the key has no value in the map.

source

pub fn set_by_index(&mut self, index: EnumIndex<T>, value: Option<V>)

Sets the value associated with a given index.

source

pub fn set(&mut self, key: T, value: Option<V>)

Sets the value associated with a given key.

source

pub fn clear(&mut self)

Clears all the elements from the map.

source

pub fn is_empty(&self) -> bool

Returns true if the map is empty.

source

pub fn is_full(&self) -> bool

Returns true if the map is fully populated.

source

pub fn is_vec(&self) -> Option<EnumSize<T>>

Returns the size of a vector needed to represent the map, or None if the map is not representable by a vector.

A map is representable by vector if all the populated values are contiguous with the first key, or if the map is empty.

source

pub fn contains_index(&self, index: EnumIndex<T>) -> bool

Returns true if the map contains the index.

source

pub fn contains(&self, value: T) -> bool

Returns true if the map contains the key.

Trait Implementations§

source§

impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Default for EnumOptionMap<T, V, BitsetWord>

source§

fn default() -> Self

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

impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Drop for EnumOptionMap<T, V, BitsetWord>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V: Hash, BitsetWord: BitsetWordTrait> Hash for EnumOptionMap<T, V, BitsetWord>

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<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V: PartialEq, BitsetWord: BitsetWordTrait> PartialEq for EnumOptionMap<T, V, BitsetWord>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: EnumArrayHelper<V> + EnumSetHelper<u8>, V> TryFrom<EnumOptionMap<T, V>> for EnumMap<T, V>

§

type Error = ()

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

fn try_from(from: EnumOptionMap<T, V>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T: EnumArrayHelper<V> + EnumSetHelper<u8>, V> TryFrom<EnumOptionMap<T, V>> for EnumVec<T, V>

§

type Error = ()

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

fn try_from(from: EnumOptionMap<T, V>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V: Eq, BitsetWord: BitsetWordTrait> Eq for EnumOptionMap<T, V, BitsetWord>

Auto Trait Implementations§

§

impl<T, V, BitsetWord> RefUnwindSafe for EnumOptionMap<T, V, BitsetWord>

§

impl<T, V, BitsetWord> Send for EnumOptionMap<T, V, BitsetWord>
where <T as EnumSetHelper<BitsetWord>>::BitsetArray: Send, <T as EnumArrayHelper<V>>::PartialArray: Send,

§

impl<T, V, BitsetWord> Sync for EnumOptionMap<T, V, BitsetWord>
where <T as EnumSetHelper<BitsetWord>>::BitsetArray: Sync, <T as EnumArrayHelper<V>>::PartialArray: Sync,

§

impl<T, V, BitsetWord> Unpin for EnumOptionMap<T, V, BitsetWord>
where <T as EnumSetHelper<BitsetWord>>::BitsetArray: Unpin, <T as EnumArrayHelper<V>>::PartialArray: Unpin,

§

impl<T, V, BitsetWord> UnwindSafe for EnumOptionMap<T, V, BitsetWord>

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