Add more must_use attributes (#2846)

… so people get a warning when they accidentally add a semicolon after the response expression in a handler function.

Also update changelogs of axum-core, axum-extra.
This commit is contained in:
Jonas Platte
2024-09-11 19:17:25 +00:00
committed by GitHub
parent fdf83d0b73
commit b214e39581
6 changed files with 21 additions and 4 deletions
+11 -2
View File
@@ -7,9 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased
- **added:** Implement `Copy` for `DefaultBodyLimit`
- **added:** Derive `Clone` and `Copy` for `AppendHeaders` ([#2776])
- **added:** `must_use` attribute on `AppendHeaders` ([#2846])
- **added:** `must_use` attribute on `ErrorResponse` ([#2846])
- **added:** `must_use` attribute on `IntoResponse::into_response` ([#2846])
- **added:** `must_use` attribute on `IntoResponseParts` trait methods ([#2846])
- **added:** Implement `Copy` for `DefaultBodyLimit` ([#2875])
- **added**: `DefaultBodyLimit::max` and `DefaultBodyLimit::disable` are now
allowed in const context
allowed in const context ([#2875])
[#2776]: https://github.com/tokio-rs/axum/pull/2776
[#2846]: https://github.com/tokio-rs/axum/pull/2846
[#2875]: https://github.com/tokio-rs/axum/pull/2875
# 0.4.3 (13. January, 2024)
+1
View File
@@ -111,6 +111,7 @@ use std::{
/// ```
pub trait IntoResponse {
/// Create a response.
#[must_use]
fn into_response(self) -> Response;
}
@@ -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()
}
+1
View File
@@ -117,6 +117,7 @@ where
///
/// See [`Result`] for more details.
#[derive(Debug)]
#[must_use]
pub struct ErrorResponse(Response);
impl<T> From<T> for ErrorResponse