mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-01-14 16:46: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";
|
let pretend_user_input = "8";
|
||||||
|
|
||||||
// Don't change this line.
|
// Don't change this line.
|
||||||
let cost = total_cost(pretend_user_input)?;
|
let cost = total_cost(pretend_user_input);
|
||||||
|
|
||||||
if cost > tokens {
|
match cost {
|
||||||
println!("You can't afford that many!");
|
Ok(cost) => {
|
||||||
} else {
|
if cost > tokens {
|
||||||
tokens -= cost;
|
println!("You can't afford that many!");
|
||||||
println!("You now have {tokens} tokens.");
|
} else {
|
||||||
|
tokens -= cost;
|
||||||
|
println!("You now have {tokens} tokens.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(error) => {
|
||||||
|
println!("Error calculating the total cost: {}", error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue