pub fn repeat_until<P: Parser, R, F, T>(
    p: &mut P,
    mut term: T,
    mut parse: F,
) -> Result<Vec<R>, Recovered>
where
    F: FnMut(&mut P) -> Result<R, Reported>,
    T: Predicate<P>,
{
    let mut v = Vec::new();
    while p.peek(0).value != Eof && !term.matches(p) {
        match parse(p) {
            Ok(x) => v.push(x),
            Err(_) => {
                term.recover(p, false);
                return Err(Recovered);
            }
        }
    }
    Ok(v)
}
/// Repeatedly apply a parser until a certain predicate matches.
Repeatedly apply a parser until a certain predicate matches.
Repeatedly apply a parser until a certain predicate matches .
pub fn repeat_until<P: Parser, R, F, T>(
    p: &mut P,
    mut term: T,
    mut parse: F,
) -> Result<Vec<R>, Recovered>
where
    F: FnMut(&mut P) -> Result<R, Reported>,
    T: Predicate<P>,
{
    let mut v = Vec::new();
    while p.peek(0).value != Eof && !term.matches(p) {
        match parse(p) {
            Ok(x) => v.push(x),
            Err(_) => {
                term.recover(p, false);
                return Err(Recovered);
            }
        }
    }
    Ok(v)
}
pub fn repeat_until < P : Parser , R , F , T > ( p : & mut P , mut term : T , mut parse : F , ) -> Result < Vec < R > , Recovered > where F : FnMut ( & mut P ) -> Result < R , Reported > , T : Predicate < P > , { let mut v = Vec :: new ( ) ; while p . peek ( 0 ) . value != Eof && ! term . matches ( p ) { match parse ( p ) { Ok ( x ) => v . push ( x ) , Err ( _ ) => { term . recover ( p , false ) ; return Err ( Recovered ) ; } } } Ok ( v ) }
Repeatedly apply a parser until a certain predicate matches.
Repeatedly apply a parser until a certain predicate matches .
p
&mut P
term
T
parse
F
p
&mut P
term
T
parse
F