Function bin_digit1

fn bin_digit1<T, E: ParseError<T>>(input: T) -> crate::internal::IResult<T, T, E>
where
    T: Input,
    <T as Input>::Item: AsChar

Recognizes one or more binary characters: 0-1

Complete version: Will return an error if there's not enough input data, or the whole input if no terminating token is found (a non binary digit character).

Example

# use nom::{Err, error::{Error, ErrorKind}, IResult, Needed};
# use nom::character::complete::bin_digit1;
fn parser(input: &str) -> IResult<&str, &str> {
    bin_digit1(input)
}

assert_eq!(parser("013a"), Ok(("3a", "01")));
assert_eq!(parser("a013"), Err(Err::Error(Error::new("a013", ErrorKind::BinDigit))));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::BinDigit))));