I try to collect the directory from the user and then pass it to WalkDir to get all files inside, but it did not work. Same input was working when I hard code it. I was testing it on a Windows system.
This did not work, just return nothing.
let mut some_dir = String::new();
io::stdin()
.read_line(&mut some_dir)
.expect("Invalid Input");
some_dir = some_dir.replace("\", "\\");
for entry in WalkDir::new(&some_dir).into_iter().filter_map(|file| file.ok()) {
println!("{}", entry.path().display());
}
This worked
for entry in WalkDir::new("<dir>").into_iter().filter_map(|file| file.ok()) {
println!("{}", entry.path().display());
}
What is the reason behind and how to fix it?
New contributor
mathless-generation is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.