Function many_till

fn many_till<I, E, F, G>(f: F, g: G) -> impl Parser<I, Output = (crate::lib::std::vec::Vec<<F as Parser<I>>::Output>, <G as Parser<I>>::Output), Error = E>
where
    I: Clone + Input,
    F: Parser<I, Error = E>,
    G: Parser<I, Error = E>,
    E: ParseError<I>

Applies the parser f until the parser g produces a result.

Returns a tuple of the results of f in a Vec and the result of g.

f keeps going so long as g produces Err::Error. To instead chain an error up, see [cut][crate::combinator::cut].

# use nom::{Err, error::{Error, ErrorKind}, Needed, IResult, Parser};
use nom::multi::many_till;
use nom::bytes::complete::tag;

fn parser(s: &str) -> IResult<&str, (Vec<&str>, &str)> {
  many_till(tag("abc"), tag("end")).parse(s)
};

assert_eq!(parser("abcabcend"), Ok(("", (vec!["abc", "abc"], "end"))));
assert_eq!(parser("abc123end"), Err(Err::Error(Error::new("123end", ErrorKind::Tag))));
assert_eq!(parser("123123end"), Err(Err::Error(Error::new("123123end", ErrorKind::Tag))));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Tag))));
assert_eq!(parser("abcendefg"), Ok(("efg", (vec!["abc"], "end"))));