Skip to content

Commit

Permalink
Add dyn keyword to all trait objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgeibel committed Jul 18, 2019
1 parent 6485da3 commit 56bdfc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl conduit::Request for ConduitRequest {
conduit::Scheme::Http
}

fn headers(&self) -> &conduit::Headers {
fn headers(&self) -> &dyn conduit::Headers {
&self.parts
}

Expand Down Expand Up @@ -152,7 +152,7 @@ impl conduit::Request for ConduitRequest {
self.parts.0.uri.query()
}

fn body(&mut self) -> &mut Read {
fn body(&mut self) -> &mut dyn Read {
&mut self.body
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ impl<H: conduit::Handler> hyper::service::NewService for Service<H> {
type ResBody = Body;
type Error = hyper::Error;
type Service = Service<H>;
type Future = Box<Future<Item = Self::Service, Error = Self::InitError> + Send>;
type Future = Box<dyn Future<Item = Self::Service, Error = Self::InitError> + Send>;
type InitError = hyper::Error;

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

/// Returns a future which buffers the response body and then calls the conduit handler from a thread pool
fn call(&mut self, request: Request<Self::ReqBody>) -> Self::Future {
Expand Down
12 changes: 6 additions & 6 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hyper;

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

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

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

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

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

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

0 comments on commit 56bdfc9

Please sign in to comment.