[−][src]Trait arae::Sequence
Sequence
types are Cursed
types that provide the ability to move forwards
and backwards through their elements.
Required methods
fn next(&self, cursor: Cursor<T>) -> Option<Cursor<T>>
Given a Cursor
, return its next element step.
None
is returned if the cursor provided cannot advance any further.
fn prev(&self, cursor: Cursor<T>) -> Option<Cursor<T>>
Given a Cursor
, return its previous element step.
None
is returned if the cursor provided cannot reverse any further.
fn remaining(&self, cursor: Cursor<T>) -> (usize, Option<usize>)
Given a Cursor
, return the bounds of the remaining steps.
Specifically, remaining()
returns a tuple where the first element is
the lower bound, and the second element is the upper bound, as a known
lower and optional upper bound.
Implementation notes
As with Iterator::size_hint()
, remaining()
is primarily intended to
be used for optimizations such as reserving space for the elements of the
iterator, but must not be trusted to e.g., omit bounds checks in unsafe code.
An incorrect implementation of remaining()
should not lead to memory
safety violations.