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

§============================================================================ QUERY VALUE BOUNDARIES

Collection

Explicit iteration contract for list/set wrapper types. Avoids implicit deref-based access to inner collections.

Required Associated Types§

Source

type Item

Source

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

Iterator over the collection’s items, tied to the borrow of self.

Required Methods§

Source

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

Returns an iterator over the collection’s items.

Source

fn len(&self) -> usize

Returns the number of items in the collection.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the collection contains no items.

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§