nom::character::complete

Function bin_digit0

Source
pub fn bin_digit0<T, E: ParseError<T>>(input: T) -> IResult<T, T, E>
where T: Input, <T as Input>::Item: AsChar,
Expand description

Recognizes zero or more binary characters: 0-1

Complete version: Will return the whole input if no terminating token is found (a non binary digit character).

ยงExample

fn parser(input: &str) -> IResult<&str, &str> {
    bin_digit0(input)
}

assert_eq!(parser("013a"), Ok(("3a", "01")));
assert_eq!(parser("a013"), Ok(("a013", "")));
assert_eq!(parser(""), Ok(("", "")));