From ed4567d881cfe0c7d50326b8c63464ed48a8bd75 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Thu, 20 Oct 2022 18:14:28 -0700 Subject: [PATCH] repeated parse() refactor --- src/combinators.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/combinators.rs b/src/combinators.rs index 764c678..53fdd4e 100644 --- a/src/combinators.rs +++ b/src/combinators.rs @@ -55,16 +55,15 @@ where I: Clone + 'a, { fn parse(&self, input: I) -> ParseResult, I> { - let mut results = Vec::new(); - let mut count: u16 = 0; - let at_least = self.at_least.unwrap_or(0); let at_most = self.at_most.unwrap_or(u16::MAX); 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(); while let Ok((item, rest)) = self.inner_parser.parse(further_input.clone()) {