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>
impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> EnumOptionMap<T, V, BitsetWord>
sourcepub fn get_by_index(&self, index: EnumIndex<T>) -> Option<&V>
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.
sourcepub fn get(&self, key: T) -> Option<&V>
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.
sourcepub fn get_by_index_mut(&mut self, index: EnumIndex<T>) -> Option<&mut V>
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.
sourcepub fn get_mut(&mut self, key: T) -> Option<&mut V>
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.
sourcepub fn set_by_index(&mut self, index: EnumIndex<T>, value: Option<V>)
pub fn set_by_index(&mut self, index: EnumIndex<T>, value: Option<V>)
Sets the value associated with a given index.
sourcepub fn is_vec(&self) -> Option<EnumSize<T>>
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.
sourcepub fn contains_index(&self, index: EnumIndex<T>) -> bool
pub fn contains_index(&self, index: EnumIndex<T>) -> bool
Returns true if the map contains the index.