pub fn take_while<Input, F>(f: F) -> TakeWhile<Input, F> where
Input: RangeStream,
Input::Range: Range,
F: FnMut(Input::Token) -> bool,
Expand description
Zero-copy parser which reads a range of 0 or more tokens which satisfy f
.
many
is a non-RangeStream
alternative.
let mut parser = take_while(|c: char| c.is_digit(10));
let result = parser.parse("123abc");
assert_eq!(result, Ok(("123", "abc")));
let result = parser.parse("abc");
assert_eq!(result, Ok(("", "abc")));