Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Last active September 14, 2016 23:04
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 nixpulvis/47a73c166203f7a44e9e80a6285a3525 to your computer and use it in GitHub Desktop.
Save nixpulvis/47a73c166203f7a44e9e80a6285a3525 to your computer and use it in GitHub Desktop.
impl Node {
fn new(state: State) -> Node {
Rc::new(RefCell::new(state))
}
fn then(self, state: State) {
let arrow = Arrow::Then(self.clone());
state.arrows.push(arrow);
Node::new(state)
}
fn until(self, state: State, pred: FnOnce(&S) -> bool) {
let arrow = Arrow::Until(self.clone(), pred);
state.arrows.push(arrow)
self
}
fn times(self, state: State, mut n: usize) -> Node {
node.until(move |_| {
i -= 1;
n == 0
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment