Function utils::parser::byte

source ·
pub fn byte() -> Byte
Expand description

Parser that consumes a single byte.

Not to be confused with u8, which parses a number in the range 0-255.

§Examples

assert_eq!(
    parser::byte().parse(b"abcdef"),
    Ok((b'a', &b"bcdef"[..]))
);
assert_eq!(
    parser::byte().parse(b"123"),
    Ok((b'1', &b"23"[..]))
);