1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-01-02 05:18:44 +00:00

Add explicit dyns (#1041)

* Add explicit `dyn`s

* Remove unnecessary lines
This commit is contained in:
Yuki Okushi 2019-08-17 02:45:44 +09:00 committed by GitHub
parent 87b7162473
commit 23d768a77b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 8 deletions

View file

@ -269,9 +269,9 @@ where
.map(|protos| protos.windows(2).any(|w| w == H2)) .map(|protos| protos.windows(2).any(|w| w == H2))
.unwrap_or(false); .unwrap_or(false);
if h2 { if h2 {
(Box::new(sock) as Box<Io>, Protocol::Http2) (Box::new(sock) as Box<dyn Io>, Protocol::Http2)
} else { } else {
(Box::new(sock) as Box<Io>, Protocol::Http1) (Box::new(sock) as Box<dyn Io>, Protocol::Http1)
} }
}), }),
), ),
@ -288,9 +288,9 @@ where
.map(|protos| protos.windows(2).any(|w| w == H2)) .map(|protos| protos.windows(2).any(|w| w == H2))
.unwrap_or(false); .unwrap_or(false);
if h2 { if h2 {
(Box::new(sock) as Box<Io>, Protocol::Http2) (Box::new(sock) as Box<dyn Io>, Protocol::Http2)
} else { } else {
(Box::new(sock) as Box<Io>, Protocol::Http1) (Box::new(sock) as Box<dyn Io>, Protocol::Http1)
} }
}), }),
), ),

View file

@ -1072,7 +1072,7 @@ mod tests {
#[test] #[test]
fn test_error_casting() { fn test_error_casting() {
let err = PayloadError::Overflow; let err = PayloadError::Overflow;
let resp_err: &ResponseError = &err; let resp_err: &dyn ResponseError = &err;
let err = resp_err.downcast_ref::<PayloadError>().unwrap(); let err = resp_err.downcast_ref::<PayloadError>().unwrap();
assert_eq!(err.to_string(), "A payload reached size limit."); assert_eq!(err.to_string(), "A payload reached size limit.");
let not_err = resp_err.downcast_ref::<ContentTypeError>(); let not_err = resp_err.downcast_ref::<ContentTypeError>();

View file

@ -151,5 +151,4 @@ mod tests {
let res = block_on(normalize.call(req)).unwrap(); let res = block_on(normalize.call(req)).unwrap();
assert!(res.status().is_success()); assert!(res.status().is_success());
} }
} }

View file

@ -763,5 +763,4 @@ mod tests {
let resp = call_service(&mut srv, req); let resp = call_service(&mut srv, req);
assert_eq!(resp.status(), StatusCode::NO_CONTENT); assert_eq!(resp.status(), StatusCode::NO_CONTENT);
} }
} }

View file

@ -482,5 +482,4 @@ mod tests {
use crate::responder::tests::BodyTest; use crate::responder::tests::BodyTest;
assert_eq!(resp.body().bin_ref(), b"hello=world&counter=123"); assert_eq!(resp.body().bin_ref(), b"hello=world&counter=123");
} }
} }