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>,
) -> Option<V>
pub fn set_by_index( &mut self, index: EnumIndex<T>, value: Option<V>, ) -> Option<V>
Sets the value associated with a given index and returns the old value if one was present.
Sourcepub fn set(&mut self, key: T, value: Option<V>) -> Option<V>
pub fn set(&mut self, key: T, value: Option<V>) -> Option<V>
Sets the value associated with a given key and returns the old value if one was present.
Sourcepub fn insert_by_index(&mut self, index: EnumIndex<T>, value: V) -> Option<V>
pub fn insert_by_index(&mut self, index: EnumIndex<T>, value: V) -> Option<V>
Adds a value at the given index to the map and returns the old value if one was present.
Sourcepub fn insert(&mut self, key: T, value: V) -> Option<V>
pub fn insert(&mut self, key: T, value: V) -> Option<V>
Adds a value with the given key to the map and returns the old value if one was present.
Sourcepub fn remove_by_index(&mut self, index: EnumIndex<T>) -> Option<V>
pub fn remove_by_index(&mut self, index: EnumIndex<T>) -> Option<V>
Removes any value at the given index from the map and returns it if one was present.
Sourcepub fn remove(&mut self, key: T) -> Option<V>
pub fn remove(&mut self, key: T) -> Option<V>
Removes any value with the given key from the map and returns it if one was present.
Sourcepub fn swap_by_index(&mut self, a: EnumIndex<T>, b: EnumIndex<T>)
pub fn swap_by_index(&mut self, a: EnumIndex<T>, b: EnumIndex<T>)
Swaps two elements in the map by 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.
Sourcepub fn iter(&self) -> EnumOptionMapIter<'_, T, V, BitsetWord>
pub fn iter(&self) -> EnumOptionMapIter<'_, T, V, BitsetWord>
Returns an iterator over the keys and values.
Trait Implementations§
Source§impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord> + Debug, V: Debug, BitsetWord: BitsetWordTrait> Debug for EnumOptionMap<T, V, BitsetWord>
impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord> + Debug, V: Debug, BitsetWord: BitsetWordTrait> Debug for EnumOptionMap<T, V, BitsetWord>
Source§impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Default for EnumOptionMap<T, V, BitsetWord>
impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Default for EnumOptionMap<T, V, BitsetWord>
Source§impl<'de, T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord> + Deserialize<'de>, V: Deserialize<'de>, BitsetWord: BitsetWordTrait> Deserialize<'de> for EnumOptionMap<T, V, BitsetWord>
impl<'de, T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord> + Deserialize<'de>, V: Deserialize<'de>, BitsetWord: BitsetWordTrait> Deserialize<'de> for EnumOptionMap<T, V, BitsetWord>
Source§fn deserialize<D>(de: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(de: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Drop for EnumOptionMap<T, V, BitsetWord>
impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Drop for EnumOptionMap<T, V, BitsetWord>
impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V: Eq, BitsetWord: BitsetWordTrait> Eq for EnumOptionMap<T, V, BitsetWord>
Source§impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Extend<(T, V)> for EnumOptionMap<T, V, BitsetWord>
impl<T: EnumArrayHelper<V> + EnumSetHelper<BitsetWord>, V, BitsetWord: BitsetWordTrait> Extend<(T, V)> for EnumOptionMap<T, V, BitsetWord>
Source§fn extend<I: IntoIterator<Item = (T, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (T, V)>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)