Function chomp::combinators::sep_by
[−]
[src]
pub fn sep_by<'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
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::{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]));