How to load files in directory


Please tell me how to load files in vector of files (or array) to operate them?
I am trying write this to show the current path,but didn’t work

use std::path::{Path,Display};
fn main() {
let current_dir = &Path::new(".");
let d:Display = current_dir.display();
Thank you!


By “show the current path” I assume you mean resolve “.” to an absolute path? Rust doesn’t currently provide way to get an absolute path from a relative path however, if you just want the current directory, you should use std::env::current_dir.

If you want to list a directory, take a look at look at the std::fs::read_dir.