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

Iteration contract for generated list and set wrappers.

Required Associated Types§

Source

type Item

Element type.

Source

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

Borrowed iterator type.

Required Methods§

Source

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

Iterate over elements.

Source

fn len(&self) -> usize

Return the number of elements.

Provided Methods§

Source

fn is_empty(&self) -> bool

Return whether this collection is empty.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§