Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Joe McCain III <jo3mccain@icloud.com>
  • Loading branch information
FL03 committed Sep 2, 2024
1 parent a4d900e commit 02c6195
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 18 deletions.
6 changes: 3 additions & 3 deletions core/src/actors/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
core::mem::replace(&mut self.scope, next);
}

pub fn process<I>(&mut self) -> Result<(), Error>
pub fn process(&mut self) -> Result<(), Error>
where
A: crate::Symbolic,
Q: Clone + Eq + std::hash::Hash,
Expand All @@ -83,8 +83,8 @@ where
None => return Err(Error::runtime_error("Engine::process")),
};

if let Some(rule) = self.program.get(self.scope.state(), &symbol) {
self.handle(rule.direction, rule.state.clone(), rule.symbol.clone());
if let Some(rule) = self.program.get(self.scope.state(), symbol) {
self.handle(rule.direction, rule.state.clone(), rule.symbol);
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion core/src/actors/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
// process the instruction
self.actor.process(tail.clone());
// return the head
return Some(tail.into_head());
Some(tail.into_head())
} else {
#[cfg(feature = "tracing")]
tracing::error!("No symbol found at {}", self.actor.position());
Expand Down
6 changes: 3 additions & 3 deletions core/src/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<Q, S> Scope<Q, S> for Rule<Q, S> {
}

fn symbol(&self) -> &S {
&self.symbol()
self.symbol()
}
}

Expand All @@ -138,7 +138,7 @@ impl<Q, S> Directive<Q, S> for Rule<Q, S> {
}

fn value(&self) -> &S {
&self.write_symbol()
self.write_symbol()
}
}

Expand All @@ -162,7 +162,7 @@ impl<Q, S> Directive<Q, S> for crate::Tail<Q, S> {
}

fn value(&self) -> &S {
&self.symbol()
self.symbol()
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/rules/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod impls {
S: PartialEq,
{
fn eq(&self, other: &(Head<Q, S>, Tail<Q, S>)) -> bool {
&self.head == &other.0 && &self.tail == &other.1
self.head == other.0 && self.tail == other.1
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/state/halt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait HaltableExt<Q>: Haltable<Q> {
F: FnOnce(Q) -> U,
Self: Sized,
{
self.get().map(|state| f(state))
self.get().map(f)
}
}

Expand Down
5 changes: 4 additions & 1 deletion core/src/state/impls/impl_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ where
}
}

impl<Q> num::traits::Num for State<Q> where Q: num::traits::Num {
impl<Q> num::traits::Num for State<Q>
where
Q: num::traits::Num,
{
type FromStrRadixErr = Q::FromStrRadixErr;

fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr> {
Expand Down
5 changes: 3 additions & 2 deletions core/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ pub trait RawState {
pub trait Apply<Q, R> {
type Output;

fn apply<F>(self, f: F) -> Self::Output where F: FnOnce(Q) -> R;
fn apply<F>(self, f: F) -> Self::Output
where
F: FnOnce(Q) -> R;
}

/*
Expand Down Expand Up @@ -89,4 +91,3 @@ impl_raw_state! {
Halt(0),
State(0),
}

2 changes: 1 addition & 1 deletion core/src/state/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<Q> State<Q> {
}
/// Casts the state to a new type, returning a new instance of [State].
///
/// ### Saftey
/// # Saftey
///
/// *
pub unsafe fn cast<R>(self) -> State<R> {

Check warning

Code scanning / clippy

unsafe function's docs are missing a # Safety section Warning

unsafe function's docs are missing a # Safety section
Expand Down
2 changes: 1 addition & 1 deletion core/src/tape/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where
}

fn get_mut(&mut self, key: &Self::Key) -> Option<&mut Self::Value> {
HashMap::get_mut(self, &key)
HashMap::get_mut(self, key)
}

fn insert(&mut self, key: Self::Key, value: Self::Value) {
Expand Down
6 changes: 6 additions & 0 deletions core/src/tape/tape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ pub struct StdTape<S = char> {
ticks: Cell<usize>,
}

impl<S> Default for StdTape<S> {
fn default() -> Self {
Self::new()
}
}

impl<S> StdTape<S> {
pub fn new() -> Self {
StdTape {
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ where
S: PartialEq,
{
fn eq(&self, head: &Head<Q, S>) -> bool {
&head.state == &self.0 && &head.symbol == &self.1
head.state == self.0 && head.symbol == self.1
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/types/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<Q, S> Tail<Q, S> {
}
/// Returns an instance of the [head](Head) where each element within
/// the created instance is an immutable reference
pub fn to_head_ref<'a>(&'a self) -> Head<&'a Q, &'a S> {
pub fn to_head_ref(&self) -> Head<&Q, &S> {
super::Head::new(self.state.to_ref(), &self.symbol)
}

Expand Down
2 changes: 1 addition & 1 deletion core/tests/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn busy_beaver() {
let initial_state = State(0_isize);
let input = [0_usize; 10];

let program = Program::from_iter(RULES.clone());
let program = Program::from_iter(*RULES);

let actor = Actor::from_state(initial_state).with_alpha(input);
let mut rt = actor.execute(program);
Expand Down
2 changes: 1 addition & 1 deletion core/tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ fn numstate() {
assert_eq!(one, 1);
// verify the state has an inner value of 0
assert_eq!(zero, 0.0);
}
}

0 comments on commit 02c6195

Please sign in to comment.