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 value 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::{Input, ParseResult, many_till, any, token};

let i = Input::new(b"abc;def");

let r: ParseResult<_, Vec<u8>, _> = many_till(i, any, |i| token(i, b';'));

assert_eq!(r.unwrap(), vec![b'a', b'b', b'c']);