mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 15:26:29 +00:00
Updated TODO errors3.rs
This commit is contained in:
parent
26cf4989a2
commit
bfda4caf83
1 changed files with 13 additions and 6 deletions
|
@ -20,12 +20,19 @@ fn main() {
|
|||
let pretend_user_input = "8";
|
||||
|
||||
// Don't change this line.
|
||||
let cost = total_cost(pretend_user_input)?;
|
||||
let cost = total_cost(pretend_user_input);
|
||||
|
||||
if cost > tokens {
|
||||
println!("You can't afford that many!");
|
||||
} else {
|
||||
tokens -= cost;
|
||||
println!("You now have {tokens} tokens.");
|
||||
match cost {
|
||||
Ok(cost) => {
|
||||
if cost > tokens {
|
||||
println!("You can't afford that many!");
|
||||
} else {
|
||||
tokens -= cost;
|
||||
println!("You now have {tokens} tokens.");
|
||||
}
|
||||
},
|
||||
Err(error) => {
|
||||
println!("Error calculating the total cost: {}", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue