Created
June 28, 2017 23:28
-
-
Save CallumHoward/1930a72710b7efc557b0e7612a6c2cf6 to your computer and use it in GitHub Desktop.
prints all directories recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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