為什么我的stdin用戶輸入沒有正確匹配?我正在嘗試獲取系統(tǒng)輸入并檢查用戶是否輸入了是或否。我的字符串轉(zhuǎn)換是錯誤還是什么?if塊不執(zhí)行。use std::io;fn main() {
let mut correct_name = String::new();
io::stdin().read_line(&mut correct_name).expect("Failed to read line");
if correct_name == "y" {
println!("matched y!");
// Do something
} else if correct_name == "n" {
println!("matched n!");
// Do something else
}}
為什么我的stdin用戶輸入沒有正確匹配?
料青山看我應(yīng)如是
2019-08-23 09:49:44