1macro_rules! tuple_impls {
2 () => {
3 tuple_impls!(@impl);
4 };
5 ($T:ident $( $U:ident )*) => {
6 tuple_impls!($( $U )*);
7 tuple_impls!(@impl $T $( $U )*);
8 };
9 (@impl $( $T:ident )*) => {
11 impl<$($T,)*> FromRequest for ($($T,)*)
12 where
13 $($T: FromRequest + Send,)*
14 $($T::Error: IntoResponse + Send,)*
15 {
16 type Error = Error;
17
18 #[allow(unused, unused_mut)]
19 async fn extract(req: &mut Request) -> Result<($($T,)*), Self::Error> {
20 Ok(($($T::extract(req).await.map_err(IntoResponse::into_error)?,)*))
21 }
22 }
23
24 impl<$($T,)* Fun, Fut, Out> FnExt<Request, ($($T,)*)> for Fun
25 where
26 $($T: FromRequest + Send,)*
27 $($T::Error: IntoResponse + Send,)*
28 Fun: Fn($($T,)*) -> Fut + Send + Sync + 'static,
29 Fut: Future<Output = Result<Out>> + Send,
30 {
31 type Output = Fut::Output;
32
33 #[allow(unused, unused_mut)]
34 async fn call(&self, mut req: Request) -> Self::Output {
35 (self)($($T::extract(&mut req).await.map_err(IntoResponse::into_error)?,)*)
36 .await
37 }
38 }
39 };
40}