Revert on_response lifetimes to more closely match 0.4.

This commit is contained in:
Jeb Rosen 2019-12-10 16:34:35 -08:00 committed by Sergio Benitez
parent 4bb4c61528
commit 70096c1bd4
3 changed files with 8 additions and 8 deletions

View File

@ -53,7 +53,7 @@ enum AdHocKind {
Request(Box<dyn for<'a> Fn(&'a mut Request<'_>, &'a Data) -> BoxFuture<'a, ()> + Send + Sync + 'static>), Request(Box<dyn for<'a> Fn(&'a mut Request<'_>, &'a Data) -> BoxFuture<'a, ()> + Send + Sync + 'static>),
/// An ad-hoc **response** fairing. Called when a response is ready to be /// An ad-hoc **response** fairing. Called when a response is ready to be
/// sent to a client. /// sent to a client.
Response(Box<dyn for<'a, 'r> Fn(&'a Request<'r>, &'a mut Response<'r>) -> BoxFuture<'a, ()> + Send + Sync + 'static>), Response(Box<dyn for<'a> Fn(&'a Request<'_>, &'a mut Response<'_>) -> BoxFuture<'a, ()> + Send + Sync + 'static>),
} }
impl AdHoc { impl AdHoc {
@ -132,7 +132,7 @@ impl AdHoc {
/// }); /// });
/// ``` /// ```
pub fn on_response<F>(name: &'static str, f: F) -> AdHoc pub fn on_response<F>(name: &'static str, f: F) -> AdHoc
where F: for<'a, 'r> Fn(&'a Request<'r>, &'a mut Response<'r>) -> BoxFuture<'a, ()> + Send + Sync + 'static where F: for<'a> Fn(&'a Request<'_>, &'a mut Response<'_>) -> BoxFuture<'a, ()> + Send + Sync + 'static
{ {
AdHoc { name, kind: AdHocKind::Response(Box::new(f)) } AdHoc { name, kind: AdHocKind::Response(Box::new(f)) }
} }
@ -176,7 +176,7 @@ impl Fairing for AdHoc {
} }
} }
fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> BoxFuture<'a, ()> { fn on_response<'a>(&'a self, request: &'a Request<'_>, response: &'a mut Response<'_>) -> BoxFuture<'a, ()> {
if let AdHocKind::Response(ref callback) = self.kind { if let AdHocKind::Response(ref callback) = self.kind {
callback(request, response) callback(request, response)
} else { } else {

View File

@ -238,7 +238,7 @@ pub use self::info_kind::{Info, Kind};
/// }) /// })
/// } /// }
/// ///
/// fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> Pin<Box<dyn Future<Output=()> + Send + 'a>> { /// fn on_response<'a>(&'a self, request: &'a Request<'_>, response: &'a mut Response<'_>) -> Pin<Box<dyn Future<Output=()> + Send + 'a>> {
/// Box::pin(async move { /// Box::pin(async move {
/// // Don't change a successful user's response, ever. /// // Don't change a successful user's response, ever.
/// if response.status() != Status::NotFound { /// if response.status() != Status::NotFound {
@ -306,7 +306,7 @@ pub use self::info_kind::{Info, Kind};
/// ///
/// /// Adds a header to the response indicating how long the server took to /// /// Adds a header to the response indicating how long the server took to
/// /// process the request. /// /// process the request.
/// fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> Pin<Box<dyn Future<Output=()> + Send + 'a>> { /// fn on_response<'a>(&'a self, request: &'a Request<'_>, response: &'a mut Response<'_>) -> Pin<Box<dyn Future<Output=()> + Send + 'a>> {
/// Box::pin(async move { /// Box::pin(async move {
/// let start_time = request.local_cache(|| TimerStart(None)); /// let start_time = request.local_cache(|| TimerStart(None));
/// if let Some(Ok(duration)) = start_time.0.map(|st| st.elapsed()) { /// if let Some(Ok(duration)) = start_time.0.map(|st| st.elapsed()) {
@ -424,7 +424,7 @@ pub trait Fairing: Send + Sync + 'static {
/// ///
/// The default implementation of this method does nothing. /// The default implementation of this method does nothing.
#[allow(unused_variables)] #[allow(unused_variables)]
fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> BoxFuture<'a, ()> { fn on_response<'a>(&'a self, request: &'a Request<'_>, response: &'a mut Response<'_>) -> BoxFuture<'a, ()> {
Box::pin(async { }) Box::pin(async { })
} }
} }
@ -451,7 +451,7 @@ impl<T: Fairing> Fairing for std::sync::Arc<T> {
} }
#[inline] #[inline]
fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> BoxFuture<'a, ()> { fn on_response<'a>(&'a self, request: &'a Request<'_>, response: &'a mut Response<'_>) -> BoxFuture<'a, ()> {
(self as &T).on_response(request, response) (self as &T).on_response(request, response)
} }
} }

View File

@ -39,7 +39,7 @@ impl Fairing for Counter {
}) })
} }
fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) fn on_response<'a>(&'a self, request: &'a Request<'_>, response: &'a mut Response<'_>)
-> std::pin::Pin<Box<dyn std::future::Future<Output=()> + Send + 'a>> -> std::pin::Pin<Box<dyn std::future::Future<Output=()> + Send + 'a>>
{ {
Box::pin(async move { Box::pin(async move {