Function nom::bits::streaming::bool

source ·
pub fn bool<I, E: ParseError<(I, usize)>>(
    input: (I, usize),
) -> IResult<(I, usize), bool, E>
where I: Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength,
Expand description

Parses one specific bit as a bool.

§Example


fn parse(input: (&[u8], usize)) -> IResult<(&[u8], usize), bool> {
    bool(input)
}

assert_eq!(parse(([0b10000000].as_ref(), 0)), Ok((([0b10000000].as_ref(), 1), true)));
assert_eq!(parse(([0b10000000].as_ref(), 1)), Ok((([0b10000000].as_ref(), 2), false)));