mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-28 23:38:20 +01:00
Implement IntoResponseParts
for more tuples (#817)
This commit is contained in:
parent
5f54855b05
commit
1c8f09268b
1 changed files with 29 additions and 0 deletions
|
@ -144,3 +144,32 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_into_response_parts {
|
||||
( $($ty:ident),* $(,)? ) => {
|
||||
#[allow(non_snake_case)]
|
||||
impl<$($ty,)*> IntoResponseParts for ($($ty,)*)
|
||||
where
|
||||
$( $ty: IntoResponseParts, )*
|
||||
{
|
||||
type Error = Response;
|
||||
|
||||
fn into_response_parts(self, res: ResponseParts) -> Result<ResponseParts, Self::Error> {
|
||||
let ($($ty,)*) = self;
|
||||
|
||||
$(
|
||||
let res = match $ty.into_response_parts(res) {
|
||||
Ok(res) => res,
|
||||
Err(err) => {
|
||||
return Err(err.into_response());
|
||||
}
|
||||
};
|
||||
)*
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
all_the_tuples!(impl_into_response_parts);
|
||||
|
|
Loading…
Reference in a new issue