diff --git a/src/calc.rs b/src/calc.rs index 570dc49..9a862d7 100644 --- a/src/calc.rs +++ b/src/calc.rs @@ -510,8 +510,9 @@ impl<'a> Calculator<'a> { } fn checked_get(&self, idx: usize) -> CalculatorResult { - self.stack - .get(idx) - .ok_or(Err(CalculatorError::NotEnoughStackEntries)) + match self.stack.get(idx) { + None => Err(CalculatorError::NotEnoughStackEntries), + Some(r) => Ok(*r), + } } }