Fix is_connection_closed. (#238)

Fixes #237.
This commit is contained in:
Jacob Hoffman-Andrews
2020-11-22 12:56:58 -08:00
committed by GitHub
parent 96f6ed15d7
commit c915b236ae

View File

@@ -83,7 +83,7 @@ impl Error {
Some(e) => e,
None => return false,
};
let ioe: &Box<io::Error> = 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) {}