From 85573e0573ea6c102ad6b9fa853a8f5c684270c1 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sat, 30 Dec 2023 18:47:22 +0100 Subject: [PATCH] `impl IntoResponseParts for ()` (#2471) --- axum-core/CHANGELOG.md | 4 +++- axum-core/src/response/into_response_parts.rs | 8 ++++++++ .../tests/debug_handler/fail/wrong_return_type.stderr | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/axum-core/CHANGELOG.md b/axum-core/CHANGELOG.md index 0ae41366..abcab093 100644 --- a/axum-core/CHANGELOG.md +++ b/axum-core/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased -- None. +- **added:** Implement `IntoResponseParts` for `()` ([#2471]) + +[#2471]: https://github.com/tokio-rs/axum/pull/2471 # 0.4.2 (29. December, 2023) diff --git a/axum-core/src/response/into_response_parts.rs b/axum-core/src/response/into_response_parts.rs index 60f0b805..4be4fc55 100644 --- a/axum-core/src/response/into_response_parts.rs +++ b/axum-core/src/response/into_response_parts.rs @@ -258,3 +258,11 @@ impl IntoResponseParts for Extensions { Ok(res) } } + +impl IntoResponseParts for () { + type Error = Infallible; + + fn into_response_parts(self, res: ResponseParts) -> Result { + Ok(res) + } +} diff --git a/axum-macros/tests/debug_handler/fail/wrong_return_type.stderr b/axum-macros/tests/debug_handler/fail/wrong_return_type.stderr index cc718aae..64f030e1 100644 --- a/axum-macros/tests/debug_handler/fail/wrong_return_type.stderr +++ b/axum-macros/tests/debug_handler/fail/wrong_return_type.stderr @@ -12,7 +12,7 @@ error[E0277]: the trait bound `bool: IntoResponse` is not satisfied axum::extract::rejection::FailedToBufferBody axum::extract::rejection::LengthLimitError axum::extract::rejection::UnknownBodyError - axum::extract::rejection::InvalidUtf8 + bytes::bytes_mut::BytesMut and $N others note: required by a bound in `__axum_macros_check_handler_into_response::{closure#0}::check` --> tests/debug_handler/fail/wrong_return_type.rs:4:23