Function chomp::combinators::many_till [] [src]

pub fn many_till<'a, I, T, E, R, F, U, N, V>(i: Input<'a, I>, p: R, end: F) -> ParseResult<'a, I, T, E> where I: Copy, U: 'a, V: 'a, N: 'a, T: FromIterator<U>, R: FnMut(Input<'a, I>) -> ParseResult<'a, I, U, E>, F: FnMut(Input<'a, I>) -> ParseResult<'a, 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::{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']));