Skip to content

Instantly share code, notes, and snippets.

@eaglgenes101
Created September 3, 2018 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eaglgenes101/1dfe6d343c780fd468be05d5a9b89d23 to your computer and use it in GitHub Desktop.
Save eaglgenes101/1dfe6d343c780fd468be05d5a9b89d23 to your computer and use it in GitHub Desktop.
pub mod automaton;
pub mod state_machine;
pub mod move_state_machine;
#[cfg(test)]
mod tests {
use automaton::Automaton;
#[test]
fn fnmut_automaton_test() {
use std::ops::FnMut;
let mut i: i64 = 0;
let mut j: i64 = 1;
let k = Box::new(|r: &i64| {
i = j;
j = *r;
i
}) as Box<Automaton<i64, i64> + FnMut(i64) -> i64>;
/*
let mut a: i64 = 0;
let mut b: i64 = 1;
let s = |r: &i64| {
a = b;
b = *r;
a
} as Automaton<i64, i64>;
let k: Box<Automaton<i64, i64>> = w;*/
assert!(k.transition(&3) == 1);
assert!(k.transition(&2) == 3);
assert!(k.transition(&6) == 2);
assert!(i == 2);
assert!(j == 6);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment