Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Iterate over files in current directory

  • read_dir
use std::path::Path;

fn main() {
    let path_from_user = ".";
    let path = Path::new(path_from_user);
    match path.read_dir() {
        Ok(dh) => {
            // A ReadDir instance
            for entry in dh {
                println!("{:?}", entry);
            }
        }
        Err(err) => println!("Could not open directory '{}': {}", path_from_user, err),
    }
}