Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote or_default idiom for checking file names #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matklad
Copy link

@matklad matklad commented Jul 3, 2021

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.

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant