-
Notifications
You must be signed in to change notification settings - Fork 13.3k
impl PartialEq<ErrorKind> for io::Error
#93100
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
Conversation
This is a minor ergonomic improvement that allows directly testing for equality instead of needing to call `kind()`.
@rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
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. |
I'm not convinced it makes sense to consider an error and the wider category it falls into as 'equal'. This seems similar to adding Being able to skip (The PartialEq documentation even warns against "a comparison like the one above, which ignores some fields of the struct".) @rfcbot concern eq-to-wider-category |
@m-ou-se True, but those additional fields (like the string) are for human consumption and printing, not typically for machine consumption. That seems like a notable difference. |
That's not true for .raw_os_error() and also not for downcasting the |
Hm, the way I thought of it is that |
The wrapped error (whether an error code from the operating system or a custom dyn Error) is not used as the 'source' of the rust/library/std/src/io/error.rs Lines 800 to 807 in 84e9189
|
That's quite convincing, thank you. This would be convenient, but I agree that it may not be the right solution. In particular, if we ever added a PartialEq between |
@rfcbot cancel |
@joshtriplett proposal cancelled. |
Yeah I'll close this now, thanks! |
@ChrisDenton Thank you for trying the experiment! |
This is an ergonomic improvement that allows directly testing
io::Error
againstio::ErrorKind
instead of needing to callkind()
. Inspired by #93090.r? @joshtriplett