src/main.rs aktualisiert
hmmm
This commit is contained in:
parent
cb4c03abe9
commit
54a2beb653
11
src/main.rs
11
src/main.rs
|
@ -9,14 +9,13 @@ fn main() {
|
||||||
std::io::stdin()
|
std::io::stdin()
|
||||||
.read_line(&mut input)
|
.read_line(&mut input)
|
||||||
.expect("Failed to read line");
|
.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
|
let input = input.trim();
|
||||||
match input { // Match is a better way then chaining if/else expressions.
|
match input {
|
||||||
"y" => number += rng, // let expression would have shadowed the original variable and would have droped to soon. Use add assign insted
|
"y" => number += rng,
|
||||||
"n" => continue,
|
"n" => println!("maybe the next number"),
|
||||||
_ => {
|
_ => {
|
||||||
println!("Option unknown")
|
println!("Option unknown")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue