Trait gridit::pattern::Pattern [−][src]
pub trait Pattern { fn next_action(&mut self) -> Option<Action>; fn next_action_peek(&self) -> Option<Action>; fn repeat(&self) -> &Repeat; fn rest_steps(&self) -> Option<Vec<Step>> { ... } fn rest_positions(&self) -> Option<Vec<Position>> { ... } }
This trait is there to create pattern for the PatternIter. The implemntation should only return one variant of Action.
Variants
Action::StepFromOrigin(step_x)
ifstep_x
steps outside the grid, this Action will be ignored and next_action will be called again.Action::Jump(position_x)
ifposition_x
is outside the grid, this Action will be ignored and next_action will be called again. this action will be ignored and the nexj
Panics
- if different variants of
Action
are returned - if variant Action::StepFromOrigin does not implement
rest_steps
. - if variant Action::Jump does not implement
rest_positions
.
Required methods
fn next_action(&mut self) -> Option<Action>
[src]
Returns the next Action
or None if there are no more Action
.
fn next_action_peek(&self) -> Option<Action>
[src]
Peeks in the next Action
and returns it or None if there is no more Action
.
fn repeat(&self) -> &Repeat
[src]
Returns a reference to the Repeat
.
Provided methods
fn rest_steps(&self) -> Option<Vec<Step>>
[src]
Returns the rest of the steps. This must be implemented for Action::StepFromOrigin
.
fn rest_positions(&self) -> Option<Vec<Position>>
[src]
Returns the rest of the positions. This must be implemented for Action::Jump
.
Implementors
impl Pattern for DirectionPattern
[src]
impl Pattern for DirectionPattern
[src]impl Pattern for JumpsPattern
[src]
impl Pattern for JumpsPattern
[src]impl Pattern for SideStepsPattern
[src]
impl Pattern for SideStepsPattern
[src]impl Pattern for StepsPattern
[src]
impl Pattern for StepsPattern
[src]