Function chomp::combinators::sep_by [] [src]

pub fn sep_by<I: Input, T, E, R, F, U, N, V>(
    i: I,
    p: R,
    sep: 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 zero or more times, separated by the parser F. All matches from R will be collected into the type T: FromIterator.

If the separator or parser registers error or incomplete this parser stops and yields the collected value.

Incomplete will be propagated from R if end of input has not been read.

use chomp::prelude::{parse_only, sep_by, token};
use chomp::ascii::decimal;

let r: Result<Vec<u8>, _> = parse_only(|i| sep_by(i, decimal, |i| token(i, b';')), b"91;03;20");

assert_eq!(r, Ok(vec![91, 03, 20]));