Trait std::iter::Step
[−]
[src]
pub trait Step: PartialOrd<Self> {
fn step(&self, by: &Self) -> Option<Self>;
fn steps_between(start: &Self, end: &Self, by: &Self) -> Option<usize>;
fn steps_between_by_one(start: &Self, end: &Self) -> Option<usize>;
fn is_negative(&self) -> bool;
fn replace_one(&mut self) -> Self;
fn replace_zero(&mut self) -> Self;
fn add_one(&self) -> Self;
fn sub_one(&self) -> Self;
}Objects that can be stepped over in both directions.
The steps_between function provides a way to efficiently compare
two Step objects.
Required Methods
fn step(&self, by: &Self) -> Option<Self>
Steps self if possible.
fn steps_between(start: &Self, end: &Self, by: &Self) -> Option<usize>
Returns the number of steps between two step objects. The count is
inclusive of start and exclusive of end.
Returns None if it is not possible to calculate steps_between
without overflow.
fn steps_between_by_one(start: &Self, end: &Self) -> Option<usize>
Same as steps_between, but with a by of 1
fn is_negative(&self) -> bool
Tests whether this step is negative or not (going backwards)
fn replace_one(&mut self) -> Self
Replaces this step with 1, returning itself
fn replace_zero(&mut self) -> Self
Replaces this step with 0, returning itself
fn add_one(&self) -> Self
Adds one to this step, returning the result
fn sub_one(&self) -> Self
Subtracts one to this step, returning the result