pub trait StackedSet: Sized {
type Item;
type Shorten<'new>: StackedSet<Item = Self::Item> + 'new
where Self: 'new;
type IntoIter<'i>: Iterator<Item = &'i Self::Item> + 'i
where Self: 'i;
// Required methods
fn empty() -> Self;
fn contains_ref(&self, item: &Self::Item) -> bool;
fn extend(&mut self, new_item: Self::Item) -> Self::Shorten<'_>;
fn fork(&mut self) -> Self::Shorten<'_>;
fn iter(&self) -> Self::IntoIter<'_>;
// Provided method
fn contains(&self, item: impl Borrow<Self::Item>) -> bool { ... }
}
Expand description
Common trait for stacked set implementations. Users are intended to define their input as impl StackedSet<Item = WhateverItemTheyNeed>
, so it’s up to the user to pick the implementation
Required Associated Types§
Sourcetype Shorten<'new>: StackedSet<Item = Self::Item> + 'new
where
Self: 'new
type Shorten<'new>: StackedSet<Item = Self::Item> + 'new where Self: 'new
Intended to be the same type, but living for less time
Required Methods§
Sourcefn contains_ref(&self, item: &Self::Item) -> bool
fn contains_ref(&self, item: &Self::Item) -> bool
Checks if element is present in the set
Sourcefn extend(&mut self, new_item: Self::Item) -> Self::Shorten<'_>
fn extend(&mut self, new_item: Self::Item) -> Self::Shorten<'_>
Adds an item to the stack, returning a new instance now “containing” the item
Note, that original instance is being exclusively borrowed, i.e.
- new stacked set should not outlive it’s parent
- parent itself cannot be observed while new instance lives
Once this new instance is dropped, original stack is not supposed to contain this new type
Sourcefn fork(&mut self) -> Self::Shorten<'_>
fn fork(&mut self) -> Self::Shorten<'_>
Same as StackedSet::extend
, but does not actually extend the stackset
Intended to be used, when you need to pass StackedSet
implementor into multiple inner calls, while retaining ownership of the original one
Provided Methods§
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<Collection: SetCollection> StackedSet for CollectionSet<'_, Collection>
Available on crate feature collection
only.
impl<Collection: SetCollection> StackedSet for CollectionSet<'_, Collection>
collection
only.