我正在尝试获取系统输入并检查用户是否输入了是或否.我的字符串转换是错误还是什么?if块不执行.
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!");
} else if correct_name == "n" {
println!("matched n!");
}
}
Run Code Online (Sandbox Code Playgroud) rust ×1