Trait SetStorage

Source
pub trait SetStorage<T>: Sized {
    type Iter<'this>: Iterator<Item = T>
       where Self: 'this;
    type IntoIter: Iterator<Item = T>;

    // Required methods
    fn empty() -> Self;
    fn len(&self) -> usize;
    fn is_empty(&self) -> bool;
    fn insert(&mut self, value: T) -> bool;
    fn contains(&self, value: T) -> bool;
    fn remove(&mut self, value: T) -> bool;
    fn retain<F>(&mut self, f: F)
       where F: FnMut(T) -> bool;
    fn clear(&mut self);
    fn iter(&self) -> Self::Iter<'_>;
    fn into_iter(self) -> Self::IntoIter;
}
Expand description

The trait defining how storage works for Set.

§Type Arguments

  • T is the key being stored.

Required Associated Types§

Source

type Iter<'this>: Iterator<Item = T> where Self: 'this

Immutable iterator over storage.

Source

type IntoIter: Iterator<Item = T>

Owning iterator over the storage.

Required Methods§

Source

fn empty() -> Self

Construct empty storage.

Source

fn len(&self) -> usize

Get the length of storage.

Source

fn is_empty(&self) -> bool

Check if storage is empty.

Source

fn insert(&mut self, value: T) -> bool

This is the storage abstraction for Set::insert.

Source

fn contains(&self, value: T) -> bool

This is the storage abstraction for Set::contains.

Source

fn remove(&mut self, value: T) -> bool

This is the storage abstraction for Set::remove.

Source

fn retain<F>(&mut self, f: F)
where F: FnMut(T) -> bool,

This is the storage abstraction for Set::retain.

Source

fn clear(&mut self)

This is the storage abstraction for Set::clear.

Source

fn iter(&self) -> Self::Iter<'_>

This is the storage abstraction for Set::iter.

Source

fn into_iter(self) -> Self::IntoIter

This is the storage abstraction for Set::into_iter.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SetStorage<bool> for BooleanSetStorage

Source§

type Iter<'this> = Iter

Source§

type IntoIter = Iter

Source§

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

Source§

type IntoIter = Chain<Map<<<T as Key>::SetStorage as SetStorage<T>>::IntoIter, fn(T) -> Option<T>>, IntoIter<Option<T>>>

Source§

impl<T> SetStorage<T> for HashbrownSetStorage<T>
where T: Copy + Eq + Hash,

Source§

type Iter<'this> = Copied<Iter<'this, T>> where T: 'this

Source§

type IntoIter = IntoIter<T>

Source§

impl<T> SetStorage<T> for SingletonSetStorage
where T: Default,