Function bool

fn bool<Input, Error: ParserError<(Input, usize)>>(input: &mut (Input, usize)) -> Result<bool, Error>
where
    Input: Stream<Token = u8> + StreamIsPartial + Clone

Parses one specific bit as a bool.

Effective Signature

Assuming you are parsing a (&[u8], usize) bit [Stream]:

# use winnow::prelude::*;;
# use winnow::error::ContextError;
pub fn bool(input: &mut (&[u8], usize)) -> ModalResult<bool>
# {
#     winnow::binary::bits::bool.parse_next(input)
# }

Example

# use winnow::prelude::*;
# use winnow::Bytes;
# use winnow::error::InputError;
use winnow::binary::bits::bool;

type Stream<'i> = &'i Bytes;

fn stream(b: &[u8]) -> Stream<'_> {
    Bytes::new(b)
}

fn parse(input: &mut (Stream<'_>, usize)) -> ModalResult<bool> {
    bool.parse_next(input)
}

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