src/main.rs aktualisiert

hmmm
This commit is contained in:
robin 2024-05-10 13:56:57 +02:00
parent cb4c03abe9
commit 54a2beb653

View file

@ -9,14 +9,13 @@ fn main() {
std::io::stdin()
.read_line(&mut input)
.expect("Failed to read line");
let input = input.trim(); // Parse is for numbers we use letters here. A &str is more usefull in this case as we dont want to mutate it
match input { // Match is a better way then chaining if/else expressions.
"y" => number += rng, // let expression would have shadowed the original variable and would have droped to soon. Use add assign insted
"n" => continue,
let input = input.trim();
match input {
"y" => number += rng,
"n" => println!("maybe the next number"),
_ => {
println!("Option unknown")
}
}
}
}
}