fnmain() { let dir = WalkDir::new(Path::new("src")); for d in dir.into_iter().filter_map(|e| e.ok()) { println!("{}", d.path().display()); } }
跳过文件或目录
use walkdir::WalkDir; use std::path::Path;
fnmain() { let dir = WalkDir::new(Path::new("src"));
for c in dir.into_iter() .filter_entry(|e| { let x = e.file_name() .to_str() .map(|f| f.starts_with(".")) .unwrap_or(false); x }) { let entry = c.unwrap(); println!("{}", entry.path().display()); }