rustmax::nom::character

Function anychar

Source
pub fn anychar<T, E>(input: T) -> Result<(T, char), Err<E>>
where E: ParseError<T>, T: Input, <T as Input>::Item: AsChar,
Expand description

accept a str, but not a &[u8], unlike many other nom parsers.

ยงExample

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

assert_eq!(parser("abc"), Ok(("bc",'a')));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Eof))));