I wanna test if a file gived by an user input, exist with this code :
let mut path_file = String::new();
// input example : path_file = input("C:/Users/.../.../.../file.DAT");
match io::stdin().read_line(&mut path_file) {
Ok(n) => {
let path: bool = Path::new(&path_file).exists();
// let path: bool = Path::new("C:/Users/.../.../.../file.DAT").exists();
if path {
read_file_fo(Path::new(&path_file));
} else {
println!("...");
}
}
Err(error) => println!("error : {}", error),
}
However, the condition is always false. If I hardcoded directly the path :
let path: bool = Path::new("C:/Users/.../.../.../file.DAT").exists();
instead of :
let path: bool = Path::new(&path_file).exists();
The script run well.
Someone can explain why?