#[repr(C)]pub struct Rule<Q1 = String, A = char, Q2 = Q1, B = A>{
pub head: Head<Q1, A>,
pub tail: Tail<Q2, B>,
}Expand description
The Rule implementation is a concrete representation of a single instruction, or rule,
within a given Turing machine program. It encapsulates the necessary components to define
the behavior of the Turing machine when it encounters a specific state and symbol.
Note: The inner fields are flattened for serialization purposes when using serde;
this means that the fields of the Head and Tail structs will be serialized as if they
were direct fields of the Rule struct itself.
Fields§
§head: Head<Q1, A>§tail: Tail<Q2, B>Implementations§
Source§impl<Q, A, R, B> Rule<Q, A, R, B>
impl<Q, A, R, B> Rule<Q, A, R, B>
Sourcepub const fn new(head: Head<Q, A>, tail: Tail<R, B>) -> Self
pub const fn new(head: Head<Q, A>, tail: Tail<R, B>) -> Self
returns a new instance of the Rule from the given head and tail
Sourcepub const fn init() -> RuleBuilder<Q, A, R, B>
pub const fn init() -> RuleBuilder<Q, A, R, B>
returns a new instance of a RuleBuilder for constructing a new Rule
Sourcepub const fn from_parts(
state: Q,
symbol: A,
direction: Direction,
next_state: R,
write_symbol: B,
) -> Self
pub const fn from_parts( state: Q, symbol: A, direction: Direction, next_state: R, write_symbol: B, ) -> Self
initialize a new instance of the Rule from its consituent parts
Sourcepub fn with_head(self, head: Head<Q, A>) -> Self
pub fn with_head(self, head: Head<Q, A>) -> Self
consumes the current object to create another with the given head
Sourcepub fn with_tail(self, tail: Tail<R, B>) -> Self
pub fn with_tail(self, tail: Tail<R, B>) -> Self
consumes the current object to create another with the given tail
Sourcepub const fn head_view(&self) -> Head<&Q, &A>
pub const fn head_view(&self) -> Head<&Q, &A>
returns an instance of the Head whose elements are immutable references
Sourcepub const fn tail_view(&self) -> Tail<&R, &B>
pub const fn tail_view(&self) -> Tail<&R, &B>
returns an instance of the Tail whose elements are immutable references
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 of the system
Sourcepub const fn symbol_mut(&mut self) -> &mut A
pub const fn symbol_mut(&mut self) -> &mut A
returns a mutable reference to the symbol of the Head
Sourcepub const fn next_state(&self) -> &State<R>
pub const fn next_state(&self) -> &State<R>
returns the next State of the system
Sourcepub const fn next_state_mut(&mut self) -> &mut State<R>
pub const fn next_state_mut(&mut self) -> &mut State<R>
returns a mutable reference to the next State of the system
Sourcepub const fn next_symbol(&self) -> &B
pub const fn next_symbol(&self) -> &B
returns the symbol which will be written by the Head
Sourcepub const fn next_symbol_mut(&mut self) -> &mut B
pub const fn next_symbol_mut(&mut self) -> &mut B
returns a mutable reference to the next symbol
Sourcepub const fn write_symbol(&self) -> &B
pub const fn write_symbol(&self) -> &B
returns the value which for which the current object will be replaced with
Sourcepub const fn write_symbol_mut(&mut self) -> &mut B
pub const fn write_symbol_mut(&mut self) -> &mut B
returns a mutable reference to the next symbol
Sourcepub fn set_direction(&mut self, direction: Direction)
pub fn set_direction(&mut self, direction: Direction)
Sourcepub fn set_symbol(&mut self, symbol: A)
pub fn set_symbol(&mut self, symbol: A)
update the current symbol and return a mutable reference to the Rule
Sourcepub fn set_next_state(&mut self, state: R)
pub fn set_next_state(&mut self, state: R)
Sourcepub fn set_next_symbol(&mut self, symbol: B)
pub fn set_next_symbol(&mut self, symbol: B)
updates the next symbol and returns a mutable reference to the Rule
Sourcepub fn into_tuple(self) -> (Head<Q, A>, Tail<R, B>)
pub fn into_tuple(self) -> (Head<Q, A>, Tail<R, B>)
Sourcepub fn into_next_head(self) -> Head<R, B>
pub fn into_next_head(self) -> Head<R, B>
consumes the current object and returns the next Head of the system
Source§impl<Q, A> Rule<Q, usize, Q, A>where
Q: RawState,
impl<Q, A> Rule<Q, usize, Q, A>where
Q: RawState,
Trait Implementations§
Source§impl<Q, S> BorrowMut<Head<Q, S>> for Rule<Q, S>where
Q: RawState,
impl<Q, S> BorrowMut<Head<Q, S>> for Rule<Q, S>where
Q: RawState,
Source§fn borrow_mut(&mut self) -> &mut Head<Q, S>
fn borrow_mut(&mut self) -> &mut Head<Q, S>
Source§impl<Q, S> BorrowMut<Tail<Q, S>> for Rule<Q, S>where
Q: RawState,
impl<Q, S> BorrowMut<Tail<Q, S>> for Rule<Q, S>where
Q: RawState,
Source§fn borrow_mut(&mut self) -> &mut Tail<Q, S>
fn borrow_mut(&mut self) -> &mut Tail<Q, S>
Source§impl<Q, A> Extend<Rule<Q, A>> for InstructionSet<Q, A>where
Q: RawState,
impl<Q, A> Extend<Rule<Q, A>> for InstructionSet<Q, A>where
Q: RawState,
Source§fn extend<I: IntoIterator<Item = Rule<Q, A>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Rule<Q, A>>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)