Skip to main content

AnySet

Trait AnySet 

Source
pub trait AnySet<T> {
    // Required methods
    fn contains(&self, value: &T) -> bool;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait for any collection that supports efficient containment checks.

This allows SmallSet to perform set operations (like difference or is_subset) against standard library sets (HashSet, BTreeSet) without converting them first.

Required Methods§

Source

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

Returns true if the collection contains the value.

Source

fn len(&self) -> usize

Returns the number of elements in the collection.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the collection is empty.

Implementations on Foreign Types§

Source§

impl<T> AnySet<T> for BTreeSet<T>
where T: Ord,

Source§

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

Source§

fn len(&self) -> usize

Source§

impl<T, S> AnySet<T> for HashSet<T, S>
where T: Eq + Hash, S: BuildHasher,

Source§

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

Source§

fn len(&self) -> usize

Implementors§

Source§

impl<T, const N: usize> AnySet<T> for SmallBTreeSet<T, N>
where T: Ord,

Source§

impl<T, const N: usize> AnySet<T> for SmallOrderedSet<T, N>
where T: Eq + Hash,

Source§

impl<T, const N: usize> AnySet<T> for SmallSet<T, N>
where T: Eq + Hash,