repeated parse() refactor

This commit is contained in:
Greg Shuflin 2022-10-20 18:14:28 -07:00
parent 282398c7b1
commit ed4567d881

View File

@ -55,16 +55,15 @@ where
I: Clone + 'a, I: Clone + 'a,
{ {
fn parse(&self, input: I) -> ParseResult<I, Vec<O>, I> { fn parse(&self, input: I) -> ParseResult<I, Vec<O>, I> {
let mut results = Vec::new();
let mut count: u16 = 0;
let at_least = self.at_least.unwrap_or(0); let at_least = self.at_least.unwrap_or(0);
let at_most = self.at_most.unwrap_or(u16::MAX); let at_most = self.at_most.unwrap_or(u16::MAX);
if at_most == 0 { if at_most == 0 {
return Ok((results, input)); return Ok((vec![], input));
} }
let mut results = Vec::new();
let mut count: u16 = 0;
let mut further_input = input.clone(); let mut further_input = input.clone();
while let Ok((item, rest)) = self.inner_parser.parse(further_input.clone()) { while let Ok((item, rest)) = self.inner_parser.parse(further_input.clone()) {