Impl 'Deref' to 'Request' for 'LocalRequest'.

This commit is contained in:
Sergio Benitez 2021-03-04 21:50:37 -08:00
parent 671246e90c
commit 5977fe1236
3 changed files with 22 additions and 0 deletions

View File

@ -132,3 +132,11 @@ impl std::fmt::Debug for LocalRequest<'_> {
self._request().fmt(f) self._request().fmt(f)
} }
} }
impl<'c> std::ops::Deref for LocalRequest<'c> {
type Target = Request<'c>;
fn deref(&self) -> &Self::Target {
self.inner()
}
}

View File

@ -71,3 +71,11 @@ impl std::fmt::Debug for LocalRequest<'_> {
self._request().fmt(f) self._request().fmt(f)
} }
} }
impl<'c> std::ops::Deref for LocalRequest<'c> {
type Target = Request<'c>;
fn deref(&self) -> &Self::Target {
self.inner()
}
}

View File

@ -3,6 +3,9 @@ macro_rules! pub_request_impl {
{ {
/// Retrieves the inner `Request` as seen by Rocket. /// Retrieves the inner `Request` as seen by Rocket.
/// ///
/// Note that no routing has occurred and that there is no remote
/// connection.
///
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
@ -240,5 +243,8 @@ macro_rules! pub_request_impl {
fn _ensure_impls_exist() { fn _ensure_impls_exist() {
fn is_clone_debug<T: Clone + std::fmt::Debug>() {} fn is_clone_debug<T: Clone + std::fmt::Debug>() {}
is_clone_debug::<Self>(); is_clone_debug::<Self>();
fn is_deref_req<'a, T: std::ops::Deref<Target = Request<'a>>>() {}
is_deref_req::<Self>();
} }
}} }}