# Function nom::combinator::all_consuming

source · [−]

    pub fn all_consuming<I, O, E: ParseError<I>, F>(
        f: F
    ) -> impl FnMut(I) -> IResult<I, O, E> where
        I: InputLength,
        F: Parser<I, O, E>,

Expand description

Succeeds if all the input has been consumed by its child parser.

    use nom::combinator::all_consuming;
    use nom::character::complete::alpha1;

    let mut parser = all_consuming(alpha1);

    assert_eq!(parser("abcd"), Ok(("", "abcd")));
    assert_eq!(parser("abcd;"),Err(Err::Error((";", ErrorKind::Eof))));
    assert_eq!(parser("123abcd;"),Err(Err::Error(("123abcd;", ErrorKind::Alpha))));