#[repr(C)]pub struct Head<Q, S> {
pub state: State<Q>,
pub symbol: S,
}Expand description
The Head of a Turing machine is defined to be a two-tuple consisting of a state and a
symbol. Our implementation is generic over both the state and symbol types, allowing for
flexibility in their representation(s).
Fields§
§state: State<Q>§symbol: SImplementations§
Source§impl<Q, A> Head<Q, A>where
Q: RawState,
The base implementation of the Head type focusing on providing constructors and basic
methods for manipulating its components.
impl<Q, A> Head<Q, A>where
Q: RawState,
The base implementation of the Head type focusing on providing constructors and basic
methods for manipulating its components.
Sourcepub const fn new(state: Q, symbol: A) -> Self
pub const fn new(state: Q, symbol: A) -> Self
initialize a new instance of the Head given some state and symbol
Sourcepub fn from_state(state: Q) -> Selfwhere
A: Default,
pub fn from_state(state: Q) -> Selfwhere
A: Default,
returns a new instance of the head using the given state and a default symbol
Sourcepub fn from_symbol(symbol: A) -> Selfwhere
Q: Default,
pub fn from_symbol(symbol: A) -> Selfwhere
Q: Default,
returns a new instance of the head using the given symbol and a default state
Sourcepub fn from_tuple((state, symbol): (State<Q>, A)) -> Self
pub fn from_tuple((state, symbol): (State<Q>, A)) -> Self
Create a new instance from a 2-tuple: (state, symbol)
Sourcepub fn with_state(self, state: Q) -> Self
pub fn with_state(self, state: Q) -> Self
consumes the current instance to create another instance with the given state
Sourcepub fn with_symbol(self, symbol: A) -> Self
pub fn with_symbol(self, symbol: A) -> Self
consumes the current instance to create another instance with the given symbol
Sourcepub const fn state_mut(&mut self) -> &mut State<Q>
pub const fn state_mut(&mut self) -> &mut State<Q>
returns a mutable reference to the current State
Sourcepub const fn symbol_mut(&mut self) -> &mut A
pub const fn symbol_mut(&mut self) -> &mut A
returns a mutable reference to the current symbol
Sourcepub fn set_symbol(&mut self, symbol: A)
pub fn set_symbol(&mut self, symbol: A)
updates the current symbol
Sourcepub const fn replace(&mut self, state: State<Q>, symbol: A) -> Self
pub const fn replace(&mut self, state: State<Q>, symbol: A) -> Self
replaces the current values with the given state and symbol, returning the previous
instance of the Head
Sourcepub const fn replace_state(&mut self, state: State<Q>) -> State<Q>
pub const fn replace_state(&mut self, state: State<Q>) -> State<Q>
replace the current state with the given state, returning the
previous state
Sourcepub const fn replace_symbol(&mut self, symbol: A) -> A
pub const fn replace_symbol(&mut self, symbol: A) -> A
replace the current symbol with the given symbol, returning the
previous symbol
Sourcepub const fn swap(&mut self, other: &mut Self)
pub const fn swap(&mut self, other: &mut Self)
swap the current state and symbol with those of the given head
Sourcepub fn update(&mut self, state: Option<State<Q>>, symbol: Option<A>)
pub fn update(&mut self, state: Option<State<Q>>, symbol: Option<A>)
updates the current State and symbol
Sourcepub const fn as_tuple(&self) -> (&State<Q>, &A)
pub const fn as_tuple(&self) -> (&State<Q>, &A)
returns a reference to the current state and symbol returing a 2-tuple
Sourcepub const fn as_mut_tuple(&mut self) -> (&mut State<Q>, &mut A)
pub const fn as_mut_tuple(&mut self) -> (&mut State<Q>, &mut A)
returns a mutable reference to the current state and symbol as a 2-tuple
Sourcepub fn into_tuple(self) -> (State<Q>, A)
pub fn into_tuple(self) -> (State<Q>, A)
Consumes the head and returns the current state and symbol as a 2-tuple
Source§impl<Q, A> Head<Q, A>where
Q: RawState,
impl<Q, A> Head<Q, A>where
Q: RawState,
Sourcepub fn append(self, tail: Tail<Q, A>) -> Rule<Q, A>
pub fn append(self, tail: Tail<Q, A>) -> Rule<Q, A>
associates the given tail with the current head, returning a new Rule
Sourcepub fn read<T>(self, tape: &[T]) -> Option<&A::Output>where
A: SliceIndex<[T]>,
pub fn read<T>(self, tape: &[T]) -> Option<&A::Output>where
A: SliceIndex<[T]>,
tries reading the given tape using the head as its coordinates.