BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.24k stars 107 forks source link

Option for breadth-first search? #16

Closed lbonn closed 7 years ago

lbonn commented 7 years ago

In typical directory hierarchies, it's less efficient with a less predictable memory usage but it could be useful for streaming searches in huge directories.

Example: a fuzzy directory finder.

BurntSushi commented 7 years ago

This was how the original recursive directory iterator in std::fs worked, and a lot of people ran into problems with it for precisely that reason.

I'm not necessarily opposed to it, but I doubt it's as simple as "add an option for it." A simple option seems underwhelming compared to its impact: the entire implementation would need to change.

That means I'd like to see a breadth first iterator as a separate distinct type that implements the WalkDirIterator trait. Which itself raises some questions: do methods like skip_current_dir even make sense in a breadth first traversal? Can they be implemented efficiently?

I'm not personally inclined to work on this, but if there were a really clean way of adding it to this crate, then I think I'd be OK with it. My real preference though is for it to live in a separate crate.

BurntSushi commented 7 years ago

I'm going to close this. I'd like to see it prototyped in a separate crate first.