combine::parser::sequence

Function between

Source
pub fn between<I, L, R, P>(open: L, close: R, parser: P) -> Between<L, R, P>
where I: Stream, L: Parser<Input = I>, R: Parser<Input = I>, P: Parser<Input = I>,
Expand description

Parses open followed by parser followed by close. Returns the value of parser.

let result = between(token('['), token(']'), string("rust"))
    .parse("[rust]")
    .map(|x| x.0);
assert_eq!(result, Ok("rust"));