Skip to main content

Tail

Struct Tail 

Source
#[repr(C)]
pub struct Tail<Q, A> { pub direction: Direction, pub next_state: State<Q>, pub write_symbol: A, }
Expand description

The Tail of a rule defines the reaction of the actor under specific conditions. Specifically, it defines the next state, the symbol to write, and the direction to move

Fields§

§direction: Direction

defines the direction to move after writing the symbol

§next_state: State<Q>§write_symbol: A

Implementations§

Source§

impl<Q, A> Tail<Q, A>
where Q: RawState,

Source

pub const fn new(direction: Direction, next_state: Q, write_symbol: A) -> Self

initializes a new Tail with the given direction, state, and symbol

Source

pub const fn stay(state: Q, symbol: A) -> Self

initializes a new Tail at rest using the given state and symbol

Source

pub const fn left(state: Q, symbol: A) -> Self

initializes a new Tail moving to the left using the given state and symbol

Source

pub const fn right(state: Q, symbol: A) -> Self

initializes a new Tail moving to the right using the given state and symbol

Source

pub fn from_head(head: Head<Q, A>) -> Self

returns a new instance of the Tail using the given direction and head

Source

pub fn from_head_with_direction(head: Head<Q, A>, direction: Direction) -> Self

Source

pub const fn as_tuple(&self) -> (Direction, &State<Q>, &A)

returns the direction, state, and symbol as a 3-tuple

Source

pub fn into_tuple(self) -> (Direction, State<Q>, A)

consumes the tail and returns the direction, state, and symbol as a 3-tuple

Source

pub const fn direction(&self) -> Direction

returns a copy of the direction the head should shift after writing the symbol and updating the state.

Source

pub const fn state(&self) -> &State<Q>

returns the next state with an immutable reference to the inner value

Source

pub const fn state_mut(&mut self) -> &mut State<Q>

returns the next state with a mutable reference to the inner value

Source

pub const fn symbol(&self) -> &A

returns the symbol the head is instructed to write

Source

pub const fn symbol_mut(&mut self) -> &mut A

returns a mutable reference to the symbol of the tail

Source

pub const fn set_direction(&mut self, direction: Direction)

update the direction of the tail

Source

pub fn set_state(&mut self, state: Q)

update the configured state for the tail

Source

pub fn set_symbol(&mut self, symbol: A)

update the defined symbol for the tail

Source

pub fn with_direction(self, direction: Direction) -> Self

consumes the current instance to create another with the given Direction

Source

pub fn with_state(self, state: Q) -> Self

consumes the current instance to create another with the given state

Source

pub fn with_symbol(self, symbol: A) -> Self

Configures the tail with a new symbol

Source

pub const fn get_head(&self) -> Head<&Q, &A>

returns an instance of the Head containing references to the next state and symbol.

Source

pub fn get_head_mut(&mut self) -> Head<&mut Q, &mut A>

returns a new Head initialized with mutable references to the state and symbol

Source

pub fn into_head(self) -> Head<Q, A>

consumes the current instance of the tail to convert it into a Head containing the next state and symbol to write.

Source

pub fn into_head_tuple(self) -> (Direction, Head<Q, A>)

convert the tail into a 2-tuple consisting of a Direction and a Head

Source

pub const fn view(&self) -> Tail<&Q, &A>

returns an instance of the head where each element within the created instance is a mutable reference

Source

pub const fn view_mut(&mut self) -> Tail<&mut Q, &mut A>

returns a new Tail containing mutabl references to the state and symbol

Source§

impl<'a, Q, S> Tail<&'a Q, &'a S>
where Q: RawState,

Source

pub fn cloned(&self) -> Tail<Q, S>
where Q: Clone, S: Clone,

returns a new Tail with cloned elements

Source

pub const fn copied(&self) -> Tail<Q, S>
where Q: Copy, S: Copy,

returns a new Tail with copied elements

Source§

impl<'a, Q, S> Tail<&'a mut Q, &'a mut S>
where Q: RawState,

Source

pub fn cloned(&self) -> Tail<Q, S>
where Q: Clone, S: Clone,

returns a new Tail with cloned elements

Source

pub const fn copied(&self) -> Tail<Q, S>
where Q: Copy, S: Copy,

returns a new Tail with copied elements

Trait Implementations§

Source§

impl<Q, A, R, B> Add<Head<Q, A>> for Tail<R, B>
where Q: RawState, R: RawState,

Source§

type Output = Rule<Q, A, R, B>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Head<Q, A>) -> Self::Output

Performs the + operation. Read more
Source§

impl<Q, A, R, B> Add<Tail<R, B>> for Head<Q, A>
where Q: RawState, R: RawState,

Source§

type Output = Rule<Q, A, R, B>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Tail<R, B>) -> Self::Output

Performs the + operation. Read more
Source§

impl<Q, S> AsMut<Tail<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn as_mut(&mut self) -> &mut Tail<Q, S>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<Q, S> AsRef<Tail<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn as_ref(&self) -> &Tail<Q, S>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Q, A> Borrow<Direction> for Tail<Q, A>
where Q: RawState,

Source§

fn borrow(&self) -> &Direction

Immutably borrows from an owned value. Read more
Source§

impl<Q, A> Borrow<State<Q>> for Tail<Q, A>
where Q: RawState,

Source§

fn borrow(&self) -> &State<Q>

Immutably borrows from an owned value. Read more
Source§

impl<Q, S> Borrow<Tail<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn borrow(&self) -> &Tail<Q, S>

Immutably borrows from an owned value. Read more
Source§

impl<Q, A> BorrowMut<State<Q>> for Tail<Q, A>
where Q: RawState,

Source§

fn borrow_mut(&mut self) -> &mut State<Q>

Mutably borrows from an owned value. Read more
Source§

impl<Q, S> BorrowMut<Tail<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn borrow_mut(&mut self) -> &mut Tail<Q, S>

Mutably borrows from an owned value. Read more
Source§

impl<Q: Clone, A: Clone> Clone for Tail<Q, A>

Source§

fn clone(&self) -> Tail<Q, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Q, A> Debug for Tail<Q, A>
where Q: Debug, A: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Q: Default, A: Default> Default for Tail<Q, A>

Source§

fn default() -> Tail<Q, A>

Returns the “default value” for a type. Read more
Source§

impl<Q, S> Display for Tail<Q, S>
where Q: Display, S: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Q, A> From<(Direction, Head<Q, A>)> for Tail<Q, A>

Source§

fn from((direction, head): (Direction, Head<Q, A>)) -> Self

Converts to this type from the input type.
Source§

impl<Q, A> From<(Direction, Q, A)> for Tail<Q, A>

Source§

fn from((direction, next_state, write_symbol): (Direction, Q, A)) -> Self

Converts to this type from the input type.
Source§

impl<Q, A> From<(Direction, State<Q>, A)> for Tail<Q, A>

Source§

fn from((direction, next_state, write_symbol): (Direction, State<Q>, A)) -> Self

Converts to this type from the input type.
Source§

impl<Q, A> From<Tail<Q, A>> for (Direction, Head<Q, A>)

Source§

fn from(tail: Tail<Q, A>) -> Self

Converts to this type from the input type.
Source§

impl<Q, A> From<Tail<Q, A>> for (Direction, State<Q>, A)

Source§

fn from(tail: Tail<Q, A>) -> Self

Converts to this type from the input type.
Source§

impl<Q: Hash, A: Hash> Hash for Tail<Q, A>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Q: Ord, A: Ord> Ord for Tail<Q, A>

Source§

fn cmp(&self, other: &Tail<Q, A>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Q, A> PartialEq<(Direction, Head<Q, A>)> for Tail<Q, A>
where Q: PartialEq, A: PartialEq,

Source§

fn eq(&self, (other_direction, other_head): &(Direction, Head<Q, A>)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q, A> PartialEq<(Direction, State<Q>, A)> for Tail<Q, A>
where Q: PartialEq, A: PartialEq,

Source§

fn eq( &self, (other_direction, other_state, other_symbol): &(Direction, State<Q>, A), ) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q, A> PartialEq<(State<Q>, A)> for Tail<Q, A>
where Q: PartialEq, A: PartialEq,

Source§

fn eq(&self, (other_state, other_symbol): &(State<Q>, A)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q, A> PartialEq<Tail<Q, A>> for (Direction, State<Q>, A)
where Q: PartialEq, A: PartialEq,

Source§

fn eq(&self, other: &Tail<Q, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q, A> PartialEq<Tail<Q, A>> for (State<Q>, A)
where Q: PartialEq, A: PartialEq,

Source§

fn eq(&self, other: &Tail<Q, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q, S> PartialEq<Tail<Q, S>> for Rule<Q, S>
where Q: RawState + PartialEq, S: PartialEq,

Source§

fn eq(&self, other: &Tail<Q, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q: PartialEq, A: PartialEq> PartialEq for Tail<Q, A>

Source§

fn eq(&self, other: &Tail<Q, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Q: PartialOrd, A: PartialOrd> PartialOrd for Tail<Q, A>

Source§

fn partial_cmp(&self, other: &Tail<Q, A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Q, A> RawTail for Tail<Q, A>
where Q: RawState,

Source§

fn direction(&self) -> Direction

returns the direction of the tail.

Source§

fn next_state(&self) -> &State<Q>

returns an immutable reference to the next state.

Source§

fn write_symbol(&self) -> &A

returns an immutable reference to the symbol to write.

Source§

type State = Q

Source§

type Symbol = A

Source§

impl<Q, A> RawTailMut for Tail<Q, A>
where Q: RawState,

Source§

fn direction_mut(&mut self) -> &mut Direction

returns a mutable reference to the direction of the tail.

Source§

fn next_state_mut(&mut self) -> &mut State<Q>

returns a mutable reference to the next state.

Source§

fn write_symbol_mut(&mut self) -> &mut A

returns a mutable reference to the symbol to write.

Source§

impl<Q, A> TailRepr for Tail<Q, A>
where Q: RawState,

Source§

fn new(direction: Direction, next_state: Q, write_symbol: A) -> Self

creates a new tail from the given direction, next state, and symbol to write

Source§

fn right(next_state: Self::State, write_symbol: Self::Symbol) -> Self

creates a new tail that moves right after writing the symbol and transitioning to the next state
Source§

fn left(next_state: Self::State, write_symbol: Self::Symbol) -> Self

creates a new tail that moves left after writing the symbol and transitioning to the next state
Source§

fn stay(next_state: Self::State, write_symbol: Self::Symbol) -> Self

Source§

impl<Q: Copy, A: Copy> Copy for Tail<Q, A>

Source§

impl<Q: Eq, A: Eq> Eq for Tail<Q, A>

Source§

impl<Q, A> StructuralPartialEq for Tail<Q, A>

Auto Trait Implementations§

§

impl<Q, A> Freeze for Tail<Q, A>
where A: Freeze, Q: Freeze,

§

impl<Q, A> RefUnwindSafe for Tail<Q, A>

§

impl<Q, A> Send for Tail<Q, A>
where A: Send, Q: Send,

§

impl<Q, A> Sync for Tail<Q, A>
where A: Sync, Q: Sync,

§

impl<Q, A> Unpin for Tail<Q, A>
where A: Unpin, Q: Unpin,

§

impl<Q, A> UnwindSafe for Tail<Q, A>
where A: UnwindSafe, Q: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<Q, A, T> IntoHead<Q, A> for T
where T: Into<Head<Q, A>>,

Source§

fn into_head(self) -> Head<Q, A>

Source§

impl<U, Q> IntoState<Q> for U
where Q: RawState, U: Into<State<Q>>,

Source§

fn __private__(&self) -> Seal

Source§

fn into_state(self) -> State<Q>

Source§

impl<Q, A, T> IntoTail<Q, A> for T
where T: Into<Tail<Q, A>>,

Source§

fn into_tail(self) -> Tail<Q, A>

Source§

impl<U, Q> Stateful<Q> for U
where U: Borrow<State<Q>>, Q: RawState,

Source§

fn state(&self) -> &State<Q>

returns a reference to the current state
Source§

impl<S> Symbolic for S
where S: 'static + Clone + Default + Eq + Ord + Send + Sync + Debug + Display + Hash,

Source§

fn __private__(&self) -> Seal

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> Wrapper<T> for T

Source§

type Cont<U> = U

Source§

fn get(&self) -> &T

returns a reference to the inner value
Source§

fn view(&self) -> <T as Wrapper<T>>::Cont<&T>

returns a view of the container containing an immutable reference to the inner value