From 7dbfa917fb9ff770f4d8cf5a1578c92d669b36df Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Wed, 1 Feb 2023 19:59:38 -0330 Subject: make match expression more concise --- src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index c623af2..8bd62ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,13 +26,13 @@ impl Calculator { return; } }; - match op { - Operator::Add => self.stack.push(lhs + rhs), - Operator::Sub => self.stack.push(lhs - rhs), - Operator::Mul => self.stack.push(lhs * rhs), - Operator::Div => self.stack.push(lhs / rhs), - Operator::Exp => self.stack.push(lhs.powf(rhs)), - } + self.stack.push(match op { + Operator::Add => lhs + rhs, + Operator::Sub => lhs - rhs, + Operator::Mul => lhs * rhs, + Operator::Div => lhs / rhs, + Operator::Exp => lhs.powf(rhs), + }); } } -- cgit v1.2.3