Skip to content

Commit

Permalink
fix: prevent undesired test case
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Feb 27, 2024
1 parent 6f95052 commit 83780b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ impl CalculatorApp {
fn click_operator(&mut self, operator: Operator) {
type OP = Operator;
match (self.answer, self.value, self.last_operation) {
(None, None, _) => self.last_operation = Some(operator),
(None, None, _) => {
self.answer = Some(0.);
self.last_operation = Some(operator)
}
(None, Some(_), None) => {
self.last_operation = Some(operator);
self.answer = self.value;
self.value = None;
}
(None, Some(_), Some(_)) => {
error!("this should never happen because once we set a last_operation we should also set answer");
self.log_debug_info_for_operator_click(operator);
self.error_message = Some("Err: Unreachable".to_owned());
}
Expand Down

0 comments on commit 83780b9

Please sign in to comment.