Function recognize_separated0

Source
pub fn recognize_separated0<I, Separator, Item, Error>(
    item: Item,
    separator: Separator,
) -> impl FnMut(I) -> IResult<I, I>
where I: Input + Copy, Separator: Parser<I, Error = Error>, Item: Parser<I, Error = Error> + Copy, Error: ParseError<I>,
Expand description

Runs the item parser interlaced by the separator parser.

The main difference to the nom::multi::separated_list0 parser is, that this parser returns the recognized string without allocating a list.

If the item parser does not complete successfully at least one time, an empty list is returned.

use nom::character::complete::{alphanumeric1, char};
use snacks::recognize_separated0;

let input = "comma,separated,words other";
let result = recognize_separated0::<_, _, _, nom::error::Error<_>>(alphanumeric1, char(','))(input);
assert_eq!(Ok((" other", "comma,separated,words")), result);