BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.21k stars 106 forks source link

Promote `or_default` idiom for checking file names #151

Open matklad opened 3 years ago

matklad commented 3 years ago

Not sure how you'd feel about it, but decided to PR just in case!

unwrap_or_default() feels somewhat easier to read than .map and .unwrap_or_false. It doesn't make a big difference here, but we can use an opportunity to teach folks that this idiom exists.

Note that both version work incorrectly for non-utf8 file names, which is unfortunate, but isn't something we can do anything about in the example.