pub trait Container:
Default
+ Clone
+ 'static {
type ItemRef<'a>
where Self: 'a;
type Item<'a>
where Self: 'a;
type Iter<'a>: Iterator<Item = Self::ItemRef<'a>>;
type DrainIter<'a>: Iterator<Item = Self::Item<'a>>;
// Required methods
fn len(&self) -> usize;
fn clear(&mut self);
fn iter(&self) -> Self::Iter<'_>;
fn drain(&mut self) -> Self::DrainIter<'_>;
// Provided methods
fn push<T>(&mut self, item: T)
where Self: PushInto<T> { ... }
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§
sourcetype ItemRef<'a>
where
Self: 'a
type ItemRef<'a> where Self: 'a
The type of elements when reading non-destructively from the container.
Required Methods§
sourcefn len(&self) -> usize
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. When combining containers, the length of the result must be the sum of the individual parts.
sourcefn clear(&mut self)
fn clear(&mut self)
Remove all contents from self
while retaining allocated memory.
After calling clear
, is_empty
must return true
and len
0.