diff --git a/src/error.rs b/src/error.rs index 86ffdff..5739c43 100644 --- a/src/error.rs +++ b/src/error.rs @@ -83,7 +83,7 @@ impl Error { Some(e) => e, None => return false, }; - let ioe: &Box = match source.downcast_ref() { + let ioe: &io::Error = match source.downcast_ref() { Some(e) => e, None => return false, }; @@ -183,6 +183,17 @@ fn io_error() { assert_eq!(err.to_string(), "http://example.com/: Io: oops: too slow"); } +#[test] +fn connection_closed() { + let ioe = io::Error::new(io::ErrorKind::ConnectionReset, "connection reset"); + let err = ErrorKind::Io.new().src(ioe); + assert!(err.connection_closed()); + + let ioe = io::Error::new(io::ErrorKind::ConnectionAborted, "connection aborted"); + let err = ErrorKind::Io.new().src(ioe); + assert!(err.connection_closed()); +} + #[test] fn error_is_send_and_sync() { fn takes_send(_: impl Send) {}