I would like to ask the user to respond to a question with Y or N. Basically, I have no idea what I'm doing, but here's my attempt anyway
fn ask_confirm(question: &str) -> bool {
println!("{}",question);
loop {
match std::io::stdin().read_u8().map(|x| x as char) {
Ok('y') | Ok('Y') => return true,
Ok('n') | Ok('N') => return false,
Ok(_) => println!("y/n only please."),
Err(e) => ()
}
}
}
This causes an infinite loop. The Err(e) reads "unknown error (OS Error 8 (FormatMessageW() returned error 15105))" on Win 7. Input isn't recognized regardless.