axum-core/macros: Move IntoResponse impls below regular impl blocks (#3116)

This commit is contained in:
Tobias Bieniek 2024-12-27 11:27:44 +01:00 committed by GitHub
parent 7c934f2a83
commit fd60c8471d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,6 +47,18 @@ macro_rules! __define_rejection {
#[non_exhaustive]
pub struct $name;
impl $name {
/// Get the response body text used for this rejection.
pub fn body_text(&self) -> String {
$body.into()
}
/// Get the status code used for this rejection.
pub fn status(&self) -> http::StatusCode {
http::StatusCode::$status
}
}
impl $crate::response::IntoResponse for $name {
fn into_response(self) -> $crate::response::Response {
let status = self.status();
@ -60,18 +72,6 @@ macro_rules! __define_rejection {
}
}
impl $name {
/// Get the response body text used for this rejection.
pub fn body_text(&self) -> String {
$body.into()
}
/// Get the status code used for this rejection.
pub fn status(&self) -> http::StatusCode {
http::StatusCode::$status
}
}
impl std::fmt::Display for $name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", $body)
@ -104,6 +104,16 @@ macro_rules! __define_rejection {
{
Self($crate::Error::new(err))
}
/// Get the response body text used for this rejection.
pub fn body_text(&self) -> String {
format!(concat!($body, ": {}"), self.0).into()
}
/// Get the status code used for this rejection.
pub fn status(&self) -> http::StatusCode {
http::StatusCode::$status
}
}
impl $crate::response::IntoResponse for $name {
@ -120,18 +130,6 @@ macro_rules! __define_rejection {
}
}
impl $name {
/// Get the response body text used for this rejection.
pub fn body_text(&self) -> String {
format!(concat!($body, ": {}"), self.0).into()
}
/// Get the status code used for this rejection.
pub fn status(&self) -> http::StatusCode {
http::StatusCode::$status
}
}
impl std::fmt::Display for $name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", $body)