Function utils::parser::eof

source ·
pub fn eof() -> Eof
Expand description

Parser which matches the end of the input.

Useful when parsing a list and each item is separated by a separator, unless it is at the end of the input.

§Examples

assert_eq!(
    parser::eof().parse(b""),
    Ok(((), &b""[..]))
);
assert_eq!(
    parser::u32()
        .with_suffix(b','.or(parser::eof()))
        .parse_all("12,34,56")
        .unwrap(),
    vec![12, 34, 56],
);