mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
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:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ where
|
||||
///
|
||||
/// See [`Result`] for more details.
|
||||
#[derive(Debug)]
|
||||
#[must_use]
|
||||
pub struct ErrorResponse(Response);
|
||||
|
||||
impl<T> From<T> for ErrorResponse
|
||||
|
||||
Reference in New Issue
Block a user