changed evals unwraps to unwrap_or to stop the lack of numbers panicing

This commit is contained in:
Raatty 2018-12-04 23:21:58 +13:00
parent 73a0d968c3
commit 05ce0f6e2d
1 changed files with 2 additions and 2 deletions

View File

@ -27,8 +27,8 @@ impl Calc {
self.display(); self.display();
} }
fn eval(&mut self) { fn eval(&mut self) {
let left = self.left.parse::<u32>().unwrap(); let left = self.left.parse::<u32>().unwrap_or(0);
let right = self.right.parse::<u32>().unwrap(); let right = self.right.parse::<u32>().unwrap_or(0);
let ans = match self.operator { let ans = match self.operator {
Some(Operators::PLUS) => left + right, Some(Operators::PLUS) => left + right,
Some(Operators::MINUS) => left - right, Some(Operators::MINUS) => left - right,