From e9ef4db202d9b4a3ce70cfa995ec5e6986899f9d Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Thu, 29 Apr 2021 20:53:03 -0400 Subject: [PATCH] Fix checked_get --- src/calc.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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), + } } }