Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ impl Error {
}
}
}
#[stable(feature = "io_error_eq_errorkind", since = "1.60.0")]
impl PartialEq<ErrorKind> for Error {
fn eq(&self, other: &ErrorKind) -> bool {
self.kind() == *other
}
}

impl fmt::Debug for Repr {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
6 changes: 6 additions & 0 deletions library/std/src/io/error/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ fn test_const() {
assert!(format!("{:?}", E).contains("\"hello\""));
assert!(format!("{:?}", E).contains("NotFound"));
}

#[test]
fn test_eq_errorkind() {
let error = Error::new(ErrorKind::NotFound, "hello");
assert_eq!(error, ErrorKind::NotFound);
}