This commit is contained in:
Greg Shuflin
2024-01-26 00:07:52 -08:00
parent 8f00b77c2c
commit cbb30d3e9f
4 changed files with 81 additions and 41 deletions

14
src/sequence.rs Normal file
View File

@@ -0,0 +1,14 @@
use crate::{ParseResult, Parser};
pub fn sequence<I, O1, O2, E>(
first: impl Parser<I, O1, E>,
second: impl Parser<I, O2, E>,
) -> impl Parser<I, (O1, O2), E> {
move |input| -> ParseResult<I, (O1, O2), E> {
first.parse(input).and_then(|(result1, rest)| {
second
.parse(rest)
.map(|(result2, rest2)| ((result1, result2), rest2))
})
}
}