Skip to main content

Collection

Trait Collection 

Source
pub trait Collection: Disposable {
    type Item;
    type Iter<'a>: Iterator<Item = &'a Self::Item>
       where Self: 'a;

    // Required methods
    fn iter(&self) -> Self::Iter<'_>;
    fn size(&self) -> usize;
    fn clear(&mut self);
    fn retain<F>(&mut self, f: F) -> usize
       where F: FnMut(&Self::Item) -> bool;

    // Provided methods
    fn count<F>(&self, filter: F) -> usize
       where F: FnMut(&Self::Item) -> bool { ... }
    fn collect_into<C>(&self, out: &mut C)
       where C: Extend<Self::Item>,
             Self::Item: Clone { ... }
    fn collect(&self) -> Vec<Self::Item>
       where Self::Item: Clone { ... }
    fn is_empty(&self) -> bool { ... }
}

Required Associated Types§

Source

type Item

Source

type Iter<'a>: Iterator<Item = &'a Self::Item> where Self: 'a

Required Methods§

Source

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

Source

fn size(&self) -> usize

Source

fn clear(&mut self)

Source

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

Provided Methods§

Source

fn count<F>(&self, filter: F) -> usize
where F: FnMut(&Self::Item) -> bool,

Source

fn collect_into<C>(&self, out: &mut C)
where C: Extend<Self::Item>, Self::Item: Clone,

Source

fn collect(&self) -> Vec<Self::Item>
where Self::Item: Clone,

Source

fn is_empty(&self) -> bool

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<T> Collection for CircularQueue<T>

Source§

type Item = T

Source§

type Iter<'a> = Iter<'a, T> where Self: 'a

Source§

impl<T> Collection for LinkedDeque<T>

Source§

type Item = T

Source§

type Iter<'a> = Iter<'a, T> where Self: 'a

Source§

impl<T, C> Collection for PriorityQueue<T, C>
where C: Fn(&T, &T) -> Ordering,

Source§

type Item = T

Source§

type Iter<'a> = Iter<'a, T> where Self: 'a