Trait SetLike

Source
pub trait SetLike<T> {
    // Required methods
    fn insert(&mut self, t: T) -> bool;
    fn extend(&mut self, iter: impl Iterator<Item = T>);
    fn contains(&self, t: &T) -> bool;
    fn remove(&mut self, t: &T) -> bool;
}
Expand description

A data-structure providing the storage of non-duplicated items and the querying of their inclusion.

Required Methods§

Source

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

Insert item into the set.

Inserts some item t into the set.

Returns true iff the item was not already in the set.

Source

fn extend(&mut self, iter: impl Iterator<Item = T>)

Insert multiple items from an iterator.

Source

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

Check if a value is in the set.

Returns true iff the set contains a value equal to t.

Source

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

Remove an item from the set.

Removes the item equal to t from the set.

Returns true iff the item was previously in the set.

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.

Implementations on Foreign Types§

Source§

impl<T: Eq + PartialEq + Ord + PartialOrd> SetLike<T> for BTreeSet<T>

Source§

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

Source§

fn extend(&mut self, iter: impl Iterator<Item = T>)

Source§

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

Source§

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

Source§

impl<T: Eq + Hash> SetLike<T> for HashSet<T>

Source§

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

Source§

fn extend(&mut self, iter: impl Iterator<Item = T>)

Source§

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

Source§

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

Implementors§

Source§

impl<T: Eq + PartialEq + Ord + PartialOrd> SetLike<T> for VecSet<T>