-
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
Option::get_or_insert_default() #2876
Comments
This seems really specialized, and I don't think that we really need this. That said, there is some precedent for this:
Note, the most similar api, the |
That seems like a fine addition. |
@phaazon How are trait objects involved? Note: |
EDIT: I brainfarted. I was just trying to brainstorm out loud. 😄 |
There is no trait here @phaazon only the type
We've discussed expanding unsized type handling so that one could work more with bare trait objects, but I think here
We've no
Worse, there are presently no
Awful lot of compiler complexity for quite a niche use case. ;) |
|
Damn, what the heck was I thinking… 😆 |
I agree with @KrishnaSannasi that this seems overly specialized because:
There is however one argument for doing this: We'd often do |
The |
FWIW, I'm going to close this because small inherent API additions like this don't need an RFC, and this isn't a complicated method to implement. If anyone thinks it should be in |
For example:
instead of:
This is similar to
unwrap_or_default
.The text was updated successfully, but these errors were encountered: