From f7108245eabcd3b6977a130c6f6ebe18a958ea4b Mon Sep 17 00:00:00 2001 From: emma Date: Thu, 1 Feb 2024 10:54:28 -0700 Subject: [PATCH] rpn(1): more code cleanup --- src/rpn.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/rpn.rs b/src/rpn.rs index 0a0dd40c..5322ee6f 100644 --- a/src/rpn.rs +++ b/src/rpn.rs @@ -142,13 +142,10 @@ fn eval( }) }, _ => { - let x = &stack.pop_back().ok_or(EvaluationError { - message: "Stack is empty.".to_string(), - })?; - - let y = &stack.pop_back().ok_or(EvaluationError { - message: "Stack is empty.".to_string(), - })?; + let (x, y) = ( + &stack.pop_back().unwrap(), + &stack.pop_back().unwrap(), + ); match op { Add => &stack.push_back(y + x),