pub trait Container: Default {
type ItemRef<'a>
where Self: 'a;
type Item<'a>
where Self: 'a;
type Iter<'a>: Iterator<Item = Self::ItemRef<'a>>
where Self: 'a;
type DrainIter<'a>: Iterator<Item = Self::Item<'a>>
where Self: '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
.)
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
This number is used in progress tracking to confirm the receipt of some number
of outstanding records, and it is highly load bearing. The main restriction is
imposed on the LengthPreservingContainerBuilder
trait, whose implementors
must preserve the number of items.
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.