use std::fs;

fn main() {
	let dir = "/home/aaryaman/projects/rusty/music";
	let paths = fs::read_dir(&dir).unwrap();
	let names =|entry| {
		// entry is a Result<DirEntry, std::io::Error>
		let entry = entry.unwrap();
		// entry is a DirEntry
		let entry_path = entry.path();
		// entry_path is a PathBuf
		let file_name = entry_path.file_name().unwrap();
		// file_name is OsStr

		let file_name_as_str = file_name.to_str().unwrap();
		let file_name_as_string = String::from(file_name_as_str);



	println!("{:?}", names);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter