We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 26cf498 commit bfda4caCopy full SHA for bfda4ca
exercises/13_error_handling/errors3.rs
@@ -20,12 +20,19 @@ fn main() {
20
let pretend_user_input = "8";
21
22
// Don't change this line.
23
- let cost = total_cost(pretend_user_input)?;
+ let cost = total_cost(pretend_user_input);
24
25
- if cost > tokens {
26
- println!("You can't afford that many!");
27
- } else {
28
- tokens -= cost;
29
- println!("You now have {tokens} tokens.");
+ match cost {
+ Ok(cost) => {
+ if cost > tokens {
+ println!("You can't afford that many!");
+ } else {
30
+ tokens -= cost;
31
+ println!("You now have {tokens} tokens.");
32
+ }
33
+ },
34
+ Err(error) => {
35
+ println!("Error calculating the total cost: {}", error)
36
37
}
38
0 commit comments