Skip to content

Commit 56bdfc9

Browse files
committed
Add dyn keyword to all trait objects
1 parent 6485da3 commit 56bdfc9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl conduit::Request for ConduitRequest {
104104
conduit::Scheme::Http
105105
}
106106

107-
fn headers(&self) -> &conduit::Headers {
107+
fn headers(&self) -> &dyn conduit::Headers {
108108
&self.parts
109109
}
110110

@@ -152,7 +152,7 @@ impl conduit::Request for ConduitRequest {
152152
self.parts.0.uri.query()
153153
}
154154

155-
fn body(&mut self) -> &mut Read {
155+
fn body(&mut self) -> &mut dyn Read {
156156
&mut self.body
157157
}
158158
}
@@ -214,7 +214,7 @@ impl<H: conduit::Handler> hyper::service::NewService for Service<H> {
214214
type ResBody = Body;
215215
type Error = hyper::Error;
216216
type Service = Service<H>;
217-
type Future = Box<Future<Item = Self::Service, Error = Self::InitError> + Send>;
217+
type Future = Box<dyn Future<Item = Self::Service, Error = Self::InitError> + Send>;
218218
type InitError = hyper::Error;
219219

220220
fn new_service(&self) -> Self::Future {
@@ -226,7 +226,7 @@ impl<H: conduit::Handler> hyper::service::Service for Service<H> {
226226
type ReqBody = Body;
227227
type ResBody = Body;
228228
type Error = hyper::Error;
229-
type Future = Box<Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send>;
229+
type Future = Box<dyn Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send>;
230230

231231
/// Returns a future which buffers the response body and then calls the conduit handler from a thread pool
232232
fn call(&mut self, request: Request<Self::ReqBody>) -> Self::Future {

src/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use hyper;
88

99
struct OkResult;
1010
impl Handler for OkResult {
11-
fn call(&self, _req: &mut Request) -> Result<Response, Box<Error + Send>> {
11+
fn call(&self, _req: &mut dyn Request) -> Result<Response, Box<dyn Error + Send>> {
1212
Ok(Response {
1313
status: (200, "OK"),
1414
headers: build_headers("value"),
@@ -19,22 +19,22 @@ impl Handler for OkResult {
1919

2020
struct ErrorResult;
2121
impl Handler for ErrorResult {
22-
fn call(&self, _req: &mut Request) -> Result<Response, Box<Error + Send>> {
22+
fn call(&self, _req: &mut dyn Request) -> Result<Response, Box<dyn Error + Send>> {
2323
let error = ::std::io::Error::last_os_error();
2424
Err(Box::new(error))
2525
}
2626
}
2727

2828
struct Panic;
2929
impl Handler for Panic {
30-
fn call(&self, _req: &mut Request) -> Result<Response, Box<Error + Send>> {
30+
fn call(&self, _req: &mut dyn Request) -> Result<Response, Box<dyn Error + Send>> {
3131
panic!()
3232
}
3333
}
3434

3535
struct InvalidHeader;
3636
impl Handler for InvalidHeader {
37-
fn call(&self, _req: &mut Request) -> Result<Response, Box<Error + Send>> {
37+
fn call(&self, _req: &mut dyn Request) -> Result<Response, Box<dyn Error + Send>> {
3838
let mut headers = build_headers("discarded");
3939
headers.insert("invalid".into(), vec!["\r\n".into()]);
4040
Ok(Response {
@@ -47,7 +47,7 @@ impl Handler for InvalidHeader {
4747

4848
struct InvalidStatus;
4949
impl Handler for InvalidStatus {
50-
fn call(&self, _req: &mut Request) -> Result<Response, Box<Error + Send>> {
50+
fn call(&self, _req: &mut dyn Request) -> Result<Response, Box<dyn Error + Send>> {
5151
Ok(Response {
5252
status: (1000, "invalid status code"),
5353
headers: build_headers("discarded"),
@@ -58,7 +58,7 @@ impl Handler for InvalidStatus {
5858

5959
struct AssertPathNormalized;
6060
impl Handler for AssertPathNormalized {
61-
fn call(&self, req: &mut Request) -> Result<Response, Box<Error + Send>> {
61+
fn call(&self, req: &mut dyn Request) -> Result<Response, Box<dyn Error + Send>> {
6262
if req.path() == "/normalized" {
6363
OkResult.call(req)
6464
} else {

0 commit comments

Comments
 (0)