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
sourceimpl<T> Clone for OptionSetStorage<T>where
T: Key,
T::SetStorage: Clone,
impl<T> Clone for OptionSetStorage<T>where
T: Key,
T::SetStorage: Clone,
sourceimpl<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,
sourceimpl<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.
sourcefn insert(&mut self, value: Option<T>) -> bool
fn insert(&mut self, value: Option<T>) -> bool
This is the storage abstraction for
Set::insert
.sourcefn contains(&self, value: Option<T>) -> bool
fn contains(&self, value: Option<T>) -> bool
This is the storage abstraction for
Set::contains
.sourcefn remove(&mut self, key: Option<T>) -> bool
fn remove(&mut self, key: Option<T>) -> bool
This is the storage abstraction for
Set::remove
.sourcefn 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
.sourcefn clear(&mut self)
fn clear(&mut self)
This is the storage abstraction for
Set::clear
.sourcefn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
This is the storage abstraction for
Set::into_iter
.impl<T> Copy for OptionSetStorage<T>where
T: Key,
T::SetStorage: Copy,
impl<T> Eq for OptionSetStorage<T>where
T: Key,
T::SetStorage: Eq,
Auto Trait Implementations
impl<T> RefUnwindSafe for OptionSetStorage<T>where
<T as Key>::SetStorage: RefUnwindSafe,
impl<T> Send for OptionSetStorage<T>where
<T as Key>::SetStorage: Send,
impl<T> Sync for OptionSetStorage<T>where
<T as Key>::SetStorage: Sync,
impl<T> Unpin for OptionSetStorage<T>where
<T as Key>::SetStorage: Unpin,
impl<T> UnwindSafe for OptionSetStorage<T>where
<T as Key>::SetStorage: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more