changed evals unwraps to unwrap_or to stop the lack of numbers panicing
This commit is contained in:
parent
73a0d968c3
commit
05ce0f6e2d
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue