A toy replicate of walkdir
Different from walkdir
, TreeWalker
yields DirEntry
type from the standard library. This also makes TreeWalker
unusable
on /
since you simply can't get a DirEntry
representing /
.
The traversal is done is pre-order
.
I am just curious about why walkdir
doesn't return the std DirEntry
. To verify
this, I decided to try to implement it myself. Well, I totally understand the
reason right now and it makes sense to have their customized type.
use tree_walker::TreeWalker;
fn main() {
let mut walker = TreeWalker::new("/home/steve").unwrap();
while let Some(Ok(entry)) = walker.next() {
println!("{:?}", entry);
}
}