From fe4d0425e613d74bc17e0215b2682c3f549a85ef Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Tue, 13 Apr 2021 21:54:28 -0700 Subject: [PATCH] Remove unnecessary second 'Handler' lifetimes. --- contrib/lib/src/serve.rs | 2 +- core/lib/src/catcher/handler.rs | 16 ++++++---------- core/lib/src/route/handler.rs | 12 ++++++------ examples/manual-routing/src/main.rs | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/contrib/lib/src/serve.rs b/contrib/lib/src/serve.rs index f86e5a25..a48b7d1f 100644 --- a/contrib/lib/src/serve.rs +++ b/contrib/lib/src/serve.rs @@ -356,7 +356,7 @@ impl Into> for StaticFiles { #[rocket::async_trait] impl Handler for StaticFiles { - async fn handle<'r, 's: 'r>(&'s self, req: &'r Request<'_>, data: Data) -> Outcome<'r> { + async fn handle<'r>(&self, req: &'r Request<'_>, data: Data) -> Outcome<'r> { // Get the segments as a `PathBuf`, allowing dotfiles requested. let options = self.options; let allow_dotfiles = options.contains(Options::DotFiles); diff --git a/core/lib/src/catcher/handler.rs b/core/lib/src/catcher/handler.rs index 07960212..6ba41ebb 100644 --- a/core/lib/src/catcher/handler.rs +++ b/core/lib/src/catcher/handler.rs @@ -45,11 +45,7 @@ pub type BoxFuture<'r, T = Result<'r>> = futures::future::BoxFuture<'r, T>; /// /// #[rocket::async_trait] /// impl catcher::Handler for CustomHandler { -/// async fn handle<'r, 's: 'r>( -/// &'s self, -/// status: Status, -/// req: &'r Request<'_> -/// ) -> catcher::Result<'r> { +/// async fn handle<'r>(&self, status: Status, req: &'r Request<'_>) -> catcher::Result<'r> { /// let inner = match self.0 { /// Kind::Simple => "simple".respond_to(req)?, /// Kind::Intermediate => "intermediate".respond_to(req)?, @@ -101,21 +97,21 @@ pub trait Handler: Cloneable + Send + Sync + 'static { /// Nevertheless, failure is allowed, both for convenience and necessity. If /// an error handler fails, Rocket's default `500` catcher is invoked. If it /// succeeds, the returned `Response` is used to respond to the client. - async fn handle<'r, 's: 'r>(&'s self, status: Status, req: &'r Request<'_>) -> Result<'r>; + async fn handle<'r>(&self, status: Status, req: &'r Request<'_>) -> Result<'r>; } // We write this manually to avoid double-boxing. impl Handler for F where for<'x> F: Fn(Status, &'x Request<'_>) -> BoxFuture<'x>, { - fn handle<'r, 's: 'r, 'life0, 'async_trait>( - &'s self, + fn handle<'r, 'life0, 'life1, 'async_trait>( + &'life0 self, status: Status, - req: &'r Request<'life0>, + req: &'r Request<'life1>, ) -> BoxFuture<'r> where 'r: 'async_trait, - 's: 'async_trait, 'life0: 'async_trait, + 'life1: 'async_trait, Self: 'async_trait, { self(status, req) diff --git a/core/lib/src/route/handler.rs b/core/lib/src/route/handler.rs index 9472b86e..9a5b4833 100644 --- a/core/lib/src/route/handler.rs +++ b/core/lib/src/route/handler.rs @@ -53,7 +53,7 @@ pub type BoxFuture<'r, T = Outcome<'r>> = futures::future::BoxFuture<'r, T>; /// /// #[rocket::async_trait] /// impl Handler for CustomHandler { -/// async fn handle<'r, 's: 'r>(&'s self, req: &'r Request<'_>, data: Data) -> Outcome<'r> { +/// async fn handle<'r>(&self, req: &'r Request<'_>, data: Data) -> Outcome<'r> { /// match self.0 { /// Kind::Simple => Outcome::from(req, "simple"), /// Kind::Intermediate => Outcome::from(req, "intermediate"), @@ -145,7 +145,7 @@ pub trait Handler: Cloneable + Send + Sync + 'static { /// generate a response. Otherwise, if the return value is `Forward(Data)`, /// the next matching route is attempted. If there are no other matching /// routes, the `404` error catcher is invoked. - async fn handle<'r, 's: 'r>(&'s self, request: &'r Request<'_>, data: Data) -> Outcome<'r>; + async fn handle<'r>(&self, request: &'r Request<'_>, data: Data) -> Outcome<'r>; } // We write this manually to avoid double-boxing. @@ -153,14 +153,14 @@ impl Handler for F where for<'x> F: Fn(&'x Request<'_>, Data) -> BoxFuture<'x>, { #[inline(always)] - fn handle<'r, 's: 'r, 'life0, 'async_trait>( - &'s self, - req: &'r Request<'life0>, + fn handle<'r, 'life0, 'life1, 'async_trait>( + &'life0 self, + req: &'r Request<'life1>, data: Data, ) -> BoxFuture<'r> where 'r: 'async_trait, - 's: 'async_trait, 'life0: 'async_trait, + 'life1: 'async_trait, Self: 'async_trait, { self(req, data) diff --git a/examples/manual-routing/src/main.rs b/examples/manual-routing/src/main.rs index a7921bda..79c5685e 100644 --- a/examples/manual-routing/src/main.rs +++ b/examples/manual-routing/src/main.rs @@ -80,7 +80,7 @@ impl CustomHandler { #[rocket::async_trait] impl route::Handler for CustomHandler { - async fn handle<'r, 's: 'r>(&'s self, req: &'r Request<'_>, data: Data) -> route::Outcome<'r> { + async fn handle<'r>(&self, req: &'r Request<'_>, data: Data) -> route::Outcome<'r> { let self_data = self.data; let id = req.param::<&str>(0) .and_then(|res| res.ok())