Adjust one_or_more

This commit is contained in:
Greg Shuflin 2022-10-16 17:25:12 -07:00
parent ec1406a057
commit c6b3f51e42

View File

@ -156,18 +156,19 @@ where
fn one_or_more<P, I, O>(parser: P) -> impl Parser<I, Vec<O>, I>
where
P: Parser<I, O, I>,
I: Copy,
P: Parser<I, O, I> + 'static,
I: Copy + 'static,
O: 'static,
{
let parser = std::rc::Rc::new(parser);
map(
seq(parser.clone(), zero_or_more(parser)),
|(first, rest)| {
parser
.clone()
.then(zero_or_more(parser))
.map(|(first, rest)| {
let mut output = vec![first];
output.extend(rest.into_iter());
output
},
)
})
}
/// Parses a standard identifier in a programming language