diff --git a/ast/src/ast.rs b/ast/src/ast.rs index 8506abf29d..a41bf13806 100644 --- a/ast/src/ast.rs +++ b/ast/src/ast.rs @@ -159,12 +159,11 @@ impl<'ast> FromPest<'ast> for Expression<'ast> { type Rule = Rule; fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result> { - let mut clone = pest.clone(); - let pair = clone.next().ok_or(::from_pest::ConversionError::NoMatch)?; + let pair = pest.peek().ok_or(::from_pest::ConversionError::NoMatch)?; match pair.as_rule() { Rule::expression => { - // Transfer iterated state to pest. - *pest = clone; + // advance the iterator + pest.next(); Ok(PRECEDENCE_CLIMBER.climb(pair.into_inner(), parse_term, binary_expression)) } _ => Err(ConversionError::NoMatch),