Skip to content

Instantly share code, notes, and snippets.

@CallumHoward
Created June 28, 2017 23:28
Show Gist options
  • Save CallumHoward/1930a72710b7efc557b0e7612a6c2cf6 to your computer and use it in GitHub Desktop.
Save CallumHoward/1930a72710b7efc557b0e7612a6c2cf6 to your computer and use it in GitHub Desktop.
prints all directories recursively
extern crate ignore;
fn main() {
use ignore::{WalkBuilder, WalkState};
WalkBuilder::new("./").build_parallel().run(|| {
Box::new(move |result| {
let dent = match result {
Err(_) => return WalkState::Continue,
Ok(dent) => dent,
};
let ft = match dent.file_type() {
None => return WalkState::Continue,
Some(ft) => ft,
};
if ft.is_dir() {
let path = match dent.path().strip_prefix("./") {
Err(_) => dent.path(),
Ok(path) => path,
};
println!("{}", path.display());
}
WalkState::Continue
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment