Skip to main content

Container

Trait Container 

Source
pub trait Container {
    type Item: ?Sized;

    // Required method
    fn contains(&self, item: &Self::Item) -> bool;
}
Expand description

A minimal abstraction for membership checks across container-like types.

This trait unifies contains behavior for common collections, strings, ranges, and maps, letting generic code ask “does this container contain this item?” without caring about the concrete type.

The associated Item type represents the element or key being queried. For maps, this is the key type; for str/String, it is str.

Required Associated Types§

Required Methods§

Source

fn contains(&self, item: &Self::Item) -> bool

Implementations on Foreign Types§

Source§

impl Container for str

Source§

type Item = str

Source§

fn contains(&self, item: &str) -> bool

Source§

impl Container for String

Source§

type Item = str

Source§

fn contains(&self, item: &Self::Item) -> bool

Source§

impl<'a, C> Container for Cow<'a, C>
where C: Container + ToOwned + ?Sized,

Source§

type Item = <C as Container>::Item

Source§

fn contains(&self, item: &Self::Item) -> bool

Source§

impl<C: Container + ?Sized> Container for &C

Source§

type Item = <C as Container>::Item

Source§

fn contains(&self, item: &Self::Item) -> bool

Source§

impl<K: Eq + Hash, V> Container for HashMap<K, V>

Source§

type Item = K

Source§

fn contains(&self, item: &K) -> bool

Source§

impl<K: Ord, V> Container for BTreeMap<K, V>

Source§

type Item = K

Source§

fn contains(&self, item: &K) -> bool

Source§

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

Source§

type Item = T

Source§

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

Source§

impl<T: Ord> Container for BTreeSet<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialEq> Container for [T]

Source§

type Item = T

Source§

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

Source§

impl<T: PartialEq> Container for LinkedList<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialEq> Container for VecDeque<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialEq> Container for Vec<T>

Source§

type Item = T

Source§

fn contains(&self, item: &Self::Item) -> bool

Source§

impl<T: PartialEq, const N: usize> Container for [T; N]

Source§

type Item = T

Source§

fn contains(&self, item: &Self::Item) -> bool

Source§

impl<T: PartialOrd> Container for Range<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialOrd> Container for RangeFrom<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialOrd> Container for RangeInclusive<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialOrd> Container for RangeTo<T>

Source§

type Item = T

Source§

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

Source§

impl<T: PartialOrd> Container for RangeToInclusive<T>

Source§

type Item = T

Source§

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

Implementors§