println!("\nFiles in upload folder:\n");
let mut dir_list:ReadDir = fs::read_dir("./").unwrap();
for entry in dir_list {
println!("- {}", entry.unwrap().file_name().into_string().unwrap())
}
if dir_list.count() == 0{
println!("Uploads folder is empty put something u wanna upload in it!")
}
This code gives an error that dir_list is moved when it's used in the for loop, and I thought I could just reference it by calling the .by_ref() function but that ended up removing all of the elements of the array in the for loop.
What I am asking for is some explanation why this happens?