Function chomp::combinators::sep_by1 [] [src]

pub fn sep_by1<'a, I, T, E, R, F, U, N, V>(i: Input<'a, I>, p: R, sep: F) -> ParseResult<'a, I, T, E> where I: Copy, U: 'a, V: 'a, N: 'a, T: FromIterator<U>, E: From<N>, R: FnMut(Input<'a, I>) -> ParseResult<'a, I, U, E>, F: FnMut(Input<'a, I>) -> ParseResult<'a, I, V, N>

Applies the parser R one or more times, separated by the parser F. All matches from R will be collected into the type T implementing IntoIterator.

If the separator or parser registers error or incomplete this parser stops and yields the collected value if at least one item has been read.

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

use chomp::{Input, sep_by1, token};
use chomp::ascii::decimal;

let i = Input::new(b"91;03;20");

let r: Vec<u8> = sep_by1(i, decimal, |i| token(i, b';')).unwrap();

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