I am writing a rust terminal music player and i got stuck when i tried to list all files inside a dir which the user entered
main.rs
use std::path::*;
use std::io::*;
fn main() {
let mut file_path = String::new();
println!("Enter music file path");
stdin().read_line(&mut file_path).unwrap();
// rusty_music::play_audio(&file_path.trim());
rusty_music::display_all_files(&Path::new(&file_path));
}
lib.rs
use rodio::{source::Source, Decoder, OutputStream};
use std::fs::*;
use std::io::BufReader;
use std::path::Path;
pub fn display_all_files(path: &Path) {
println!("{p}", p = path.display());
for file in read_dir(path).unwrap() {
println!("{:?}", file);
}
}
I was expecting to list all files and folder inside the dir Any help in fixing my code would be great