Struct fixed_map::set::storage::OptionSetStorage
source · pub struct OptionSetStorage<T>where
T: Key,{ /* private fields */ }Expand description
SetStorage for Option types.
Examples
use fixed_map::{Key, Map};
#[derive(Debug, Clone, Copy, PartialEq, Key)]
enum Part {
A,
B,
}
#[derive(Debug, Clone, Copy, PartialEq, Key)]
enum Key {
First(Option<Part>),
Second,
}
let mut a = Map::new();
a.insert(Key::First(None), 1);
a.insert(Key::First(Some(Part::A)), 2);
assert_eq!(a.get(Key::First(Some(Part::A))), Some(&2));
assert_eq!(a.get(Key::First(Some(Part::B))), None);
assert_eq!(a.get(Key::First(None)), Some(&1));
assert_eq!(a.get(Key::Second), None);
assert!(a.iter().eq([(Key::First(Some(Part::A)), &2), (Key::First(None), &1)]));
assert!(a.values().copied().eq([2, 1]));
assert!(a.keys().eq([Key::First(Some(Part::A)), Key::First(None)]));Trait Implementations§
source§impl<T> Clone for OptionSetStorage<T>where
T: Key,
T::SetStorage: Clone,
impl<T> Clone for OptionSetStorage<T>where T: Key, T::SetStorage: Clone,
source§impl<T> PartialEq<OptionSetStorage<T>> for OptionSetStorage<T>where
T: Key,
T::SetStorage: PartialEq,
impl<T> PartialEq<OptionSetStorage<T>> for OptionSetStorage<T>where T: Key, T::SetStorage: PartialEq,
source§impl<T> SetStorage<Option<T>> for OptionSetStorage<T>where
T: Key,
impl<T> SetStorage<Option<T>> for OptionSetStorage<T>where T: Key,
§type Iter<'this>
where
T: 'this = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::Iter<'this>, fn(_: T) -> Option<T>>, IntoIter<Option<T>>>
type Iter<'this> where T: 'this = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::Iter<'this>, fn(_: T) -> Option<T>>, IntoIter<Option<T>>>
Immutable iterator over storage.
§type IntoIter = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::IntoIter, fn(_: T) -> Option<T>>, IntoIter<Option<T>>>
type IntoIter = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::IntoIter, fn(_: T) -> Option<T>>, IntoIter<Option<T>>>
Owning iterator over the storage.
source§fn insert(&mut self, value: Option<T>) -> bool
fn insert(&mut self, value: Option<T>) -> bool
This is the storage abstraction for
Set::insert.source§fn contains(&self, value: Option<T>) -> bool
fn contains(&self, value: Option<T>) -> bool
This is the storage abstraction for
Set::contains.source§fn retain<F>(&mut self, func: F)where
F: FnMut(Option<T>) -> bool,
fn retain<F>(&mut self, func: F)where F: FnMut(Option<T>) -> bool,
This is the storage abstraction for
Set::retain.source§fn clear(&mut self)
fn clear(&mut self)
This is the storage abstraction for
Set::clear.source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
This is the storage abstraction for
Set::into_iter.