Trait Container

Source
pub trait Container:
    Default
    + Clone
    + 'static {
    type Item;

    // Required methods
    fn len(&self) -> usize;
    fn capacity(&self) -> usize;
    fn clear(&mut self);

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

A container transferring data through dataflow edges

A container stores a number of elements and thus is able to describe it length (len()) and whether it is empty (is_empty()). It supports removing all elements (clear).

A container must implement default. The default implementation is not required to allocate memory for variable-length components.

We require the container to be cloneable to enable efficient copies when providing references of containers to operators. Care must be taken that the type’s clone_from implementation is efficient (which is not necessarily the case when deriving Clone.) TODO: Don’t require Container: Clone

Required Associated Types§

Source

type Item

The type of elements this container holds.

Required Methods§

Source

fn len(&self) -> usize

The number of elements in this container

The length of a container must be consistent between sending and receiving it. When exchanging a container and partitioning it into pieces, the sum of the length of all pieces must be equal to the length of the original container.

Source

fn capacity(&self) -> usize

The capacity of the underlying container

Source

fn clear(&mut self)

Remove all contents from self while retaining allocated memory. After calling clear, is_empty must return true and len 0.

Provided Methods§

Source

fn is_empty(&self) -> bool

Determine if the container contains any elements, corresponding to len() == 0.

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.

Implementations on Foreign Types§

Source§

impl<T: Clone + 'static> Container for Vec<T>

Source§

type Item = T

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn capacity(&self) -> usize

Source§

fn clear(&mut self)

Source§

impl<T: Container> Container for Rc<T>

Source§

type Item = <T as Container>::Item

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn capacity(&self) -> usize

Source§

fn clear(&mut self)

Source§

impl<T: Container> Container for Arc<T>

Source§

type Item = <T as Container>::Item

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn capacity(&self) -> usize

Source§

fn clear(&mut self)

Implementors§

Source§

impl<T: Columnation + 'static> Container for TimelyStack<T>

Source§

type Item = T