Function parser_combinators::sep_by [] [src]

pub fn sep_by<F, P, S>(parser: P, separator: S) -> SepBy<F, P, S> where F: FromIterator<P::Output>, P: Parser, S: Parser<Input=P::Input>

Parses parser zero or more time separated by separator, returning a collection with the values from p. If the returned collection cannot be inferred type annotations must be supplied, either by annotating the resulting type binding let collection: Vec<_> = ... or by specializing when calling sep_by, sep_by::<Vec<_>, _, _>(...)

 let result = sep_by(digit(), token(','))
     .parse("1,2,3")
     .map(|x| x.0);
 assert_eq!(result, Ok(vec!['1', '2', '3']));