How can I list all the files of a directory in Rust? I am looking for the equivalent of the following Python code.
files = os.listdir(\'./\')
Use std::fs::read_dir(). Here's an example:
use std::fs; fn main() { let paths = fs::read_dir("./").unwrap(); for path in paths { println!("Name: {}", path.unwrap().path().display()) } }
It will simply iterate over the files and print out their names.