Last active
September 14, 2016 23:04
-
-
Save nixpulvis/47a73c166203f7a44e9e80a6285a3525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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