Add Result::expect() for consistency with Option::expect().#11140
Add Result::expect() for consistency with Option::expect().#11140Skrylar wants to merge 1 commit intorust-lang:masterfrom Skrylar:result-expect
Conversation
|
The |
|
@alexcrichton I mostly put this up because unwrap() doesn't actually use the error message; we were talking about the need for a method which did exactly that: unwraps and throws the error itself on failure. But there isn't one, and I'm not sure what to call a method that does exactly that. I made a local version with traits named |
|
What I was getting at is that this may not be the right solution for the problem at hand. You are correct in that Regardless, this needs discussion for the direction to go in. I'm personally a fan of keeping the apis small and putting an extra bound on the error type. |
|
This method is unnecessary with the option adapters - There has been a huge discussion in the past (mainly initiated by me) of whether the Both have pros and cons: Duplicating the API means redefining all The option adapter way is was has been decided on, so the For more details, see #10364. |
|
Ah, I had forgotten that! @Kimundi is right, the |
New lint [`four_forward_slashes`] Closes rust-lang#9212 changelog: New lint [`four_forward_slashes`]
Adds an "expect(M)" call to Result, which makes it consistent with Option.