Skip to content

Commit

Permalink
Formatted with cargo fmt --all
Browse files Browse the repository at this point in the history
  • Loading branch information
FL03 committed Jul 22, 2024
1 parent 0a1793c commit 194af0a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 43 deletions.
2 changes: 0 additions & 2 deletions rstm/src/programs/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ impl<Q> Program<Q> {
pub fn push(&mut self, instruction: Instruction<Q>) {
self.instructions.push(instruction);
}


}

impl<T> Extend<Instruction<T>> for Program<T> {
Expand Down
32 changes: 9 additions & 23 deletions rstm/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub(crate) mod prelude {
pub use crate::state::{State, Transition};
}


#[allow(unused)]
#[doc(hidden)]
mod private {
Expand All @@ -31,26 +30,13 @@ mod private {
Future(T),
}

pub enum StateGroup<S> where S: State {
A {
prev: S,
curr: S,
},
B {
curr: S,
next: S,
},
C {
prev: S,
next: S,
},
D {
prev: S,
curr: S,
next: S,
}
pub enum StateGroup<S>
where
S: State,
{
A { prev: S, curr: S },
B { curr: S, next: S },
C { prev: S, next: S },
D { prev: S, curr: S, next: S },
}



}
}
1 change: 1 addition & 0 deletions rstm/src/turing/context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 5 additions & 12 deletions rstm/src/turing/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ impl<T> Context<T> {
}

pub fn with_transitions(self, transitions: Vec<Transition<T>>) -> Self {
Self { transitions, ..self }
Self {
transitions,
..self
}
}

pub fn initial_state(&self) -> &State<T> {
Expand All @@ -40,8 +43,6 @@ impl<T> Context<T> {
pub fn transitions(&self) -> &Vec<Transition<T>> {
&self.transitions
}


}

///
Expand All @@ -53,11 +54,7 @@ pub struct TuringMachine {
}

impl TuringMachine {
pub fn new(
initial_state: State,
tape: Tape,
transforms: Vec<Transition>,
) -> Self {
pub fn new(initial_state: State, tape: Tape, transforms: Vec<Transition>) -> Self {
let ctx = Context::new(initial_state.clone());
let mut transitions = Registry::new();
for trs in transforms {
Expand All @@ -67,8 +64,6 @@ impl TuringMachine {
);
}



TuringMachine {
cstate: initial_state,
ctx,
Expand All @@ -89,8 +84,6 @@ impl TuringMachine {
&self.tape
}



pub fn step(&mut self) -> Result<(), FsmError> {
let cursor = self.cstate.clone();
let current_symbol = *self.tape.read()?;
Expand Down
5 changes: 1 addition & 4 deletions rstm/src/types/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ impl IntoDirection for &str {
strum::EnumIter,
strum::VariantNames,
)]
#[cfg_attr(
feature = "serde",
derive(serde::Deserialize, serde::Serialize),
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[repr(i8)]
#[strum(serialize_all = "lowercase")]
pub enum Direction {
Expand Down
4 changes: 2 additions & 2 deletions rstm/src/types/parts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use crate::prelude::{Direction, State};

/// The head of a turing machine generally speaks to the current state and symbol of the machine
/// w.r.t. the [tape](crate::types::Tape). Currently, the head simply stores a reference to the
///
/// w.r.t. the [tape](crate::types::Tape). Currently, the head simply stores a reference to the
///
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Head<T> {
Expand Down

0 comments on commit 194af0a

Please sign in to comment.