a negative answer no longer crashes the program

This commit is contained in:
Raatty 2018-12-05 22:22:39 +13:00
parent 05ce0f6e2d
commit 87c7f0cefb
1 changed files with 2 additions and 2 deletions

View File

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