Updated TODO errors3.rs

This commit is contained in:
GURUSUJAN REDDY 2024-12-26 01:53:42 +05:30 committed by GitHub
parent 26cf4989a2
commit bfda4caf83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
}
}
}