pub fn preceded<I, O1, O2, E: ParseError<I>, F, G>(
first: F,
second: G
) -> impl Parser<I, O2, E>where
I: Stream,
F: Parser<I, O1, E>,
G: Parser<I, O2, E>,
Expand description
Apply two parsers, only returning the output from the second.
Arguments
first
The opening parser.second
The second parser to get object.
Example
use winnow::sequence::preceded;
use winnow::bytes::tag;
let mut parser = preceded("abc", "efg");
assert_eq!(parser.parse_next("abcefg"), Ok(("", "efg")));
assert_eq!(parser.parse_next("abcefghij"), Ok(("hij", "efg")));
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))));