a negative answer no longer crashes the program
This commit is contained in:
parent
05ce0f6e2d
commit
87c7f0cefb
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue