Function utils::parser::take_while

source ·
pub fn take_while(f: fn(_: &u8) -> bool) -> TakeWhile<0>
Expand description

Parser for substrings consisting of bytes matching the provided function.

§Examples

let parser = parser::take_while(u8::is_ascii_lowercase);
assert_eq!(
    parser.parse(b"abc def"),
    Ok((&b"abc"[..], &b" def"[..]))
);
assert_eq!(
    parser.parse(b"ABC"),
    Ok((&b""[..], &b"ABC"[..]))
);