-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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: rename unwrap to get or remove get_ref in favour of as_ref().unwrap() #9784
Comments
I was under the impression that we were going to rename I also believe that the reason for leaving these two methods instead of making them composable was because they're likely very common patterns. |
Nominated for library backwards compatibility tag. |
+1 for |
If we rename, other types (like arcs) should be consistent. 1.0, backwards-compat |
This is fine, but please let's stop changing this. This needs to be the last change and then this method is frozen and changing it is off the table. |
I vote for |
1+ for |
One thing that's not clear to me: among Haskellers, using |
It's better to have a reusable evil method with a concise name than the current situation of many functions preferring to fail than return an |
It sounds like it might be worth going through the stdlib and converting I agree with @glehel that Rust seems to be far too free with using As a point against this in Rust, we don't have the functors/applicatives/ |
Also, we very often use use For example, something like
Mutable options also necessitate a lot of wrapping and unwrapping of values, as those cases are basically one-element containers. |
cc #13159 |
The guidelines now have a convention for these names. I will be rolling them out in a patch soon. |
The PR for Option/Result stabilization resolved this issue by deprecating |
There are already nearly identical methods named
get_ref()
andget_mut_ref()
andstd::hashmap
names the equivalent methodget
. This method doesn't always move, it's just a normal by-value method, so it should follow the same convention as other get-or-fail methods. If it used the shorter naming, replacingget_mut_ref()
withas_mut().get()
would only add a character.The text was updated successfully, but these errors were encountered: