mirror of https://github.com/rwf2/Rocket.git
Remove unnecessary second 'Handler' lifetimes.
This commit is contained in:
parent
c49585bb39
commit
fe4d0425e6
|
@ -356,7 +356,7 @@ impl Into<Vec<Route>> 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);
|
||||
|
|
|
@ -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<F: Clone + Sync + Send + 'static> 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)
|
||||
|
|
|
@ -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<F: Clone + Sync + Send + 'static> 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)
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue