[][src]Function gchemol_parser::parsers::digit1

pub fn digit1<T, E>(input: T) -> Result<(T, T), Err<E>> where
    E: ParseError<T>,
    T: InputTakeAtPosition,
    <T as InputTakeAtPosition>::Item: AsChar

Recognizes one or more ASCII numerical characters: 0-9

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

Example

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

assert_eq!(parser("21c"), Ok(("c", "21")));
assert_eq!(parser("c1"), Err(Err::Error(("c1", ErrorKind::Digit))));
assert_eq!(parser(""), Err(Err::Error(("", ErrorKind::Digit))));