pub fn delimited<I, O1, O2, O3, E: ParseError<I>, F, G, H>(
first: F,
second: G,
third: H
) -> impl Parser<I, O2, E>where
I: Stream,
F: Parser<I, O1, E>,
G: Parser<I, O2, E>,
H: Parser<I, O3, E>,
Expand description
Apply three parsers, only returning the output of the second.
Arguments
first
The first parser to apply and discard.second
The second parser to apply.third
The third parser to apply and discard.
Example
use winnow::sequence::delimited;
use winnow::bytes::tag;
let mut parser = delimited("(", "abc", ")");
assert_eq!(parser.parse_next("(abc)"), Ok(("", "abc")));
assert_eq!(parser.parse_next("(abc)def"), Ok(("def", "abc")));
assert_eq!(parser.parse_next(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Tag))));
assert_eq!(parser.parse_next("123"), Err(ErrMode::Backtrack(Error::new("123", ErrorKind::Tag))));