Function nom::character::complete::anychar

source ·
pub fn anychar<T, E: ParseError<T>>(input: T) -> IResult<T, char, E>where
    T: InputIter + InputLength + Slice<RangeFrom<usize>>,
    <T as InputIter>::Item: AsChar,
Expand description

Matches one byte as a character. Note that the input type will accept a str, but not a &[u8], unlike many other nom parsers.

Complete version: Will return an error if there’s not enough input data.

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))));