pub fn satisfy<Input, P>(predicate: P) -> Satisfy<Input, P> where
Input: Stream,
P: FnMut(Input::Token) -> bool,
Expand description
Parses a token and succeeds depending on the result of predicate
.
let mut parser = satisfy(|c| c == '!' || c == '?');
assert_eq!(parser.parse("!").map(|x| x.0), Ok('!'));
assert_eq!(parser.parse("?").map(|x| x.0), Ok('?'));