diff --git a/axum-core/src/response/into_response.rs b/axum-core/src/response/into_response.rs index 679b0cbb74..915b55eff8 100644 --- a/axum-core/src/response/into_response.rs +++ b/axum-core/src/response/into_response.rs @@ -111,6 +111,7 @@ use std::{ /// ``` pub trait IntoResponse { /// Create a response. + #[must_use] fn into_response(self) -> Response; } diff --git a/axum-core/src/response/into_response_parts.rs b/axum-core/src/response/into_response_parts.rs index 72b61bc75b..955648238d 100644 --- a/axum-core/src/response/into_response_parts.rs +++ b/axum-core/src/response/into_response_parts.rs @@ -105,21 +105,25 @@ pub struct ResponseParts { impl ResponseParts { /// Gets a reference to the response headers. + #[must_use] pub fn headers(&self) -> &HeaderMap { self.res.headers() } /// Gets a mutable reference to the response headers. + #[must_use] pub fn headers_mut(&mut self) -> &mut HeaderMap { self.res.headers_mut() } /// Gets a reference to the response extensions. + #[must_use] pub fn extensions(&self) -> &Extensions { self.res.extensions() } /// Gets a mutable reference to the response extensions. + #[must_use] pub fn extensions_mut(&mut self) -> &mut Extensions { self.res.extensions_mut() } diff --git a/axum-core/src/response/mod.rs b/axum-core/src/response/mod.rs index 6b66c60e71..dd6728b1c2 100644 --- a/axum-core/src/response/mod.rs +++ b/axum-core/src/response/mod.rs @@ -117,6 +117,7 @@ where /// /// See [`Result`] for more details. #[derive(Debug)] +#[must_use] pub struct ErrorResponse(Response); impl From for ErrorResponse diff --git a/axum-extra/src/response/attachment.rs b/axum-extra/src/response/attachment.rs index 923ad99116..2063d30f05 100644 --- a/axum-extra/src/response/attachment.rs +++ b/axum-extra/src/response/attachment.rs @@ -33,8 +33,8 @@ use tracing::error; /// # Note /// /// If you use axum with hyper, hyper will set the `Content-Length` if it is known. -/// #[derive(Debug)] +#[must_use] pub struct Attachment { inner: T, filename: Option,