为什么我的stdin用户输入没有正确匹配?
我正在尝试获取系统输入并检查用户是否输入了是或否。我的字符串转换是错误还是什么?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!");
// Do something
} else if correct_name == "n" {
println!("matched n!");
// Do something else
}}
料青山看我应如是
白猪掌柜的
眼眸繁星
随时随地看视频慕课网APP