Function chomp::combinators::many_till
[−]
[src]
pub fn many_till<I: Input, T, E, R, F, U, N, V>(
i: I,
p: R,
end: F
) -> ParseResult<I, T, E> where
T: FromIterator<U>,
E: From<N>,
R: FnMut(I) -> ParseResult<I, U, E>,
F: FnMut(I) -> ParseResult<I, V, N>,
Applies the parser R
multiple times until the parser F
succeeds and returns a
T: FromIterator
populated by the values yielded by R
. Consumes the matched part of F
.
This parser is considered incomplete if the parser R
is considered incomplete.
Errors from R
are propagated.
use chomp::prelude::{parse_only, many_till, any, token}; let r: Result<Vec<u8>, _> = parse_only(|i| many_till(i, any, |i| token(i, b';')), b"abc;def"); assert_eq!(r, Ok(vec![b'a', b'b', b'c']));