Function combine::parser::repeat::repeat_skip_until[][src]

pub fn repeat_skip_until<Input, P, E>(
    parser: P,
    end: E
) -> SkipRepeatUntil<Input, P, E> where
    <Input as StreamOnce>::Error: ParseError<<Input as StreamOnce>::Token, <Input as StreamOnce>::Range, <Input as StreamOnce>::Position>,
    Input: Stream,
    P: Parser<Input>,
    E: Parser<Input>, 
Expand description

Skips input until end is encountered or end indicates that it has committed input before failing (attempt can be used to continue skipping even if end has committed input)

    let mut char_parser = skip_until(char::digit());
    assert_eq!(char_parser.parse("abc123"), Ok(((), "123")));

    let mut byte_parser = skip_until(byte::bytes(&b"TAG"[..]));
    assert_eq!(byte_parser.parse(&b"123TAG"[..]), Ok(((), &b"TAG"[..])));
    assert!(byte_parser.parse(&b"123TATAG"[..]).is_err());

    // `attempt` must be used because the `end` will commit to `TA` before failing,
    // but we want to continue skipping
    let mut byte_parser = skip_until(attempt(byte::bytes(&b"TAG"[..])));
    assert_eq!(byte_parser.parse(&b"123TATAG"[..]), Ok(((), &b"TAG"[..])));
}