-
Notifications
You must be signed in to change notification settings - Fork 1.6k
RFC: map_or_default in Option and Result #3148
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
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 |
Hello!
Now that the issue has been opened for almost 3.5 years, I think that some arguments against
For all of these reasons, I think that it's pertinent to re-"open" the debate around this "RFC" and to add this to the What do you think about it @steffahn ? |
I'd suggest close this RFC and resubmit this as an ACP to go forward. |
@rfcbot merge |
Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
While I have mixed feelings about Option combinators, I feel like almost every use of |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
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.