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 MyKey {
First(Option<Part>),
Second,
}
let mut a = Map::new();
a.insert(MyKey::First(None), 1);
a.insert(MyKey::First(Some(Part::A)), 2);
assert_eq!(a.get(MyKey::First(Some(Part::A))), Some(&2));
assert_eq!(a.get(MyKey::First(Some(Part::B))), None);
assert_eq!(a.get(MyKey::First(None)), Some(&1));
assert_eq!(a.get(MyKey::Second), None);
assert!(a.iter().eq([(MyKey::First(Some(Part::A)), &2), (MyKey::First(None), &1)]));
assert!(a.values().copied().eq([2, 1]));
assert!(a.keys().eq([MyKey::First(Some(Part::A)), MyKey::First(None)]));
Trait Implementations§
Source§impl<T> Clone for OptionSetStorage<T>
impl<T> Clone for OptionSetStorage<T>
Source§impl<T> PartialEq for OptionSetStorage<T>
impl<T> PartialEq for OptionSetStorage<T>
Source§impl<T> SetStorage<Option<T>> for OptionSetStorage<T>where
T: Key,
impl<T> SetStorage<Option<T>> for OptionSetStorage<T>where
T: Key,
Source§type Iter<'this> = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::Iter<'this>, fn(T) -> Option<T>>, IntoIter<Option<T>>>
where
T: 'this
type Iter<'this> = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::Iter<'this>, fn(T) -> Option<T>>, IntoIter<Option<T>>> where T: 'this
Immutable iterator over storage.
Source§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)
fn retain<F>(&mut self, func: F)
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
.impl<T> Copy for OptionSetStorage<T>
impl<T> Eq for OptionSetStorage<T>
Auto Trait Implementations§
impl<T> Freeze for OptionSetStorage<T>
impl<T> RefUnwindSafe for OptionSetStorage<T>
impl<T> Send for OptionSetStorage<T>
impl<T> Sync for OptionSetStorage<T>
impl<T> Unpin for OptionSetStorage<T>
impl<T> UnwindSafe for OptionSetStorage<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more