Transition

Struct Transition 

Source
pub struct Transition<State, Effect>
where State: Eq + PartialEq + Copy, Effect: Copy,
{ pub condition: Option<Predicate>, pub to: State, pub effect: Option<Effect>, }
Expand description

Transition to next state which is validated by condition

Fields§

§condition: Option<Predicate>

Predicate that validates current character of stream. If None then transition is unconditional (i.e. succeeds for every input character)

§to: State

Next state

§effect: Option<Effect>

Side effect that is generated after successful validation of transition If None then no effect is generated

Implementations§

Source§

impl<State, Effect> Transition<State, Effect>
where State: Eq + PartialEq + Copy, Effect: Copy,

Source

pub fn new( to: State, condition: Option<Predicate>, effect: Option<Effect>, ) -> Self

Creates new transition

  • to: next state,
  • condition: predicate for character,
  • effect: side effect
Source

pub fn transit(&self, ch: char) -> (Option<State>, Option<Effect>)

Matches next state and side effect for current character

  • ch: current character (of stream)

Auto Trait Implementations§

§

impl<State, Effect> Freeze for Transition<State, Effect>
where State: Freeze, Effect: Freeze,

§

impl<State, Effect> RefUnwindSafe for Transition<State, Effect>
where State: RefUnwindSafe, Effect: RefUnwindSafe,

§

impl<State, Effect> Send for Transition<State, Effect>
where State: Send, Effect: Send,

§

impl<State, Effect> Sync for Transition<State, Effect>
where State: Sync, Effect: Sync,

§

impl<State, Effect> Unpin for Transition<State, Effect>
where State: Unpin, Effect: Unpin,

§

impl<State, Effect> UnwindSafe for Transition<State, Effect>
where State: UnwindSafe, Effect: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.