-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: map_or_default in Option and Result #3148
base: master
Are you sure you want to change the base?
Conversation
Echoing a comment from the internals thread: once we have the free function I think we should weigh that when deciding if we want to add this. It may still make sense to add this. |
As was also started in the internals thread, I am of the opinion this doesn't need an RFC. |
It's said here to submit an RFC if it is a new API. Maybe it could be argued it's a "Obvious API hole patch", but I'm not so sure. The RFC was easy enough to write, if the libs team thinks it does not need an RFC no harm done and I can make a pull request. |
Note that |
I've got a feeling this would be used far more often than |
I don't know how much of an argument this is, but in my opinion the methods So my argument would be: if Im not having a great suggestion for alternative names right now, and I'm not sure if there was previous discussion about this. If a new alternative name for |
Shall we deprecate |
No. |
Then why not add |
This adds
Option::map_or_default
andResult::map_or_default
which behave exactly like.map_or_else(Default::default, _)
would, similarly to.unwrap_or_default()
.Rendered.