BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.27k stars 109 forks source link

Document default sort order #116

Closed Timmmm closed 5 years ago

Timmmm commented 5 years ago

If you don't specify sort_by(), what order are the files/directories iterated in? Is it arbitrary but stable (i.e. if the files don't change you get the same order), or could it even change for different runs with the exact same filesystem? Do subdirectories always come first and then files, or are they mixed?

Great library by the way!

BurntSushi commented 5 years ago

Could you say why the existing documentation is insufficient? In particular:

Results are returned in depth first fashion, with directories yielded before their contents. If contents_first is true, contents are yielded before their directories. The order is unspecified but if sort_by is given, directory entries are sorted according to this function. Directory entries . and .. are always omitted.

Timmmm commented 5 years ago

I actually missed that bit (I did search for "order" and "sort" but rather unfortunately rustdoc's search doesn't actually search the text :-/).

I'll make a pull request with what the documentation would have said if it could read my mind...

BurntSushi commented 5 years ago

I'm going to close this since I do think the docs today are correct. I'd still be happy to accept a PR if there's some way to make it clearer without unnecessarily constraining the implementation.