Implement IntoResponseParts for more tuples (#817)

This commit is contained in:
David Pedersen 2022-03-03 08:07:00 +01:00 committed by GitHub
parent 5f54855b05
commit 1c8f09268b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);