Last active
July 12, 2020 18:51
-
-
Save jbr/8055a88a8a7f0e7b7684b5fed7d5d58a to your computer and use it in GitHub Desktop.
macro expansion of adding pin project to Request.req
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct Request<State> { | |
pub(crate) state: State, | |
pub(crate) req: http::Request, | |
pub(crate) route_params: Vec<Params>, | |
} | |
#[allow(single_use_lifetimes)] | |
#[allow(clippy::used_underscore_binding)] | |
const _: () = { | |
#[allow(dead_code)] | |
#[allow(clippy::mut_mut)] | |
#[allow(clippy::type_repetition_in_bounds)] | |
pub(crate) struct Projection<'__pin, State> | |
where | |
Request<State>: '__pin, | |
{ | |
pub(crate) state: &'__pin mut (State), | |
pub(crate) req: ::pin_project_lite::__private::Pin<&'__pin mut (http::Request)>, | |
pub(crate) route_params: &'__pin mut (Vec<Params>), | |
} | |
#[allow(dead_code)] | |
#[allow(clippy::type_repetition_in_bounds)] | |
pub(crate) struct ProjectionRef<'__pin, State> | |
where | |
Request<State>: '__pin, | |
{ | |
pub(crate) state: &'__pin (State), | |
pub(crate) req: ::pin_project_lite::__private::Pin<&'__pin (http::Request)>, | |
pub(crate) route_params: &'__pin (Vec<Params>), | |
} | |
impl<State> Request<State> { | |
pub(crate) fn project<'__pin>( | |
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>, | |
) -> Projection<'__pin, State> { | |
unsafe { | |
let this = self.get_unchecked_mut(); | |
Projection { | |
state: &mut this.state, | |
req: ::pin_project_lite::__private::Pin::new_unchecked(&mut this.req), | |
route_params: &mut this.route_params, | |
} | |
} | |
} | |
pub(crate) fn project_ref<'__pin>( | |
self: ::pin_project_lite::__private::Pin<&'__pin Self>, | |
) -> ProjectionRef<'__pin, State> { | |
unsafe { | |
let this = self.get_ref(); | |
ProjectionRef { | |
state: &this.state, | |
req: ::pin_project_lite::__private::Pin::new_unchecked(&this.req), | |
route_params: &this.route_params, | |
} | |
} | |
} | |
} | |
pub struct __Origin<'__pin, State> { | |
__dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>, | |
state: ::pin_project_lite::__private::AlwaysUnpin<State>, | |
req: http::Request, | |
route_params: ::pin_project_lite::__private::AlwaysUnpin<Vec<Params>>, | |
} | |
impl<'__pin, State> ::pin_project_lite::__private::Unpin for Request<State> where | |
__Origin<'__pin, State>: ::pin_project_lite::__private::Unpin | |
{ | |
} | |
trait MustNotImplDrop {} | |
#[allow(clippy::drop_bounds)] | |
impl<T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {} | |
impl<State> MustNotImplDrop for Request<State> {} | |
#[deny(safe_packed_borrows)] | |
fn __assert_not_repr_packed<State>(this: &Request<State>) { | |
&this.state; | |
&this.req; | |
&this.route_params; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment