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