Skip to main content

Collection

Trait Collection 

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

    // Required methods
    fn iter(&self) -> Self::Iter<'_>;
    fn len(&self) -> usize;

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

Explicit iteration contract for generated list and set wrapper types.

Required Associated Types§

Source

type Item

Element type exposed by the collection.

Source

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

Iterator tied to the borrow of this collection.

Required Methods§

Source

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

Iterate over the collection’s items.

Source

fn len(&self) -> usize

Return the number of items in the collection.

Provided Methods§

Source

fn is_empty(&self) -> bool

Return whether the collection contains no items.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Collection for BTreeSet<T>

Source§

type Item = T

Source§

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

Source§

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

Source§

fn len(&self) -> usize

Source§

impl<T> Collection for Vec<T>

Source§

type Item = T

Source§

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

Source§

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

Source§

fn len(&self) -> usize

Implementors§