Function nom8::character::alpha1

source ·
pub fn alpha1<T, E: ParseError<T>, const STREAMING: bool>(
    input: T
) -> IResult<T, <T as IntoOutput>::Output, E>where
    T: InputTakeAtPosition + InputIsStreaming<STREAMING> + IntoOutput,
    <T as InputTakeAtPosition>::Item: AsChar,
Expand description

Recognizes one or more lowercase and uppercase ASCII alphabetic characters: a-z, A-Z

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 alphabetic character).

Streaming version: Will return Err(nom8::Err::Incomplete(_)) if there’s not enough input data, or if no terminating token is found (a non alphabetic character).

Example

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

assert_eq!(parser("aB1c"), Ok(("1c", "aB")));
assert_eq!(parser("1c"), Err(Err::Error(Error::new("1c", ErrorKind::Alpha))));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Alpha))));
assert_eq!(alpha1::<_, (_, ErrorKind), true>(Streaming("aB1c")), Ok((Streaming("1c"), "aB")));
assert_eq!(alpha1::<_, (_, ErrorKind), true>(Streaming("1c")), Err(Err::Error((Streaming("1c"), ErrorKind::Alpha))));
assert_eq!(alpha1::<_, (_, ErrorKind), true>(Streaming("")), Err(Err::Incomplete(Needed::new(1))));