Skip to content

Commit cc611b8

Browse files
authored
Implement IntoResponse for (R,) where R: IntoResponse (#2143)
1 parent 432289d commit cc611b8

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

axum-core/src/response/into_response.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ where
398398
}
399399
}
400400

401+
impl<R> IntoResponse for (R,)
402+
where
403+
R: IntoResponse,
404+
{
405+
fn into_response(self) -> Response {
406+
let (res,) = self;
407+
res.into_response()
408+
}
409+
}
410+
401411
macro_rules! impl_into_response {
402412
( $($ty:ident),* $(,)? ) => {
403413
#[allow(non_snake_case)]

axum-macros/tests/debug_handler/fail/wrong_return_type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ error[E0277]: the trait bound `bool: IntoResponse` is not satisfied
99
&'static [u8]
1010
&'static str
1111
()
12+
(R,)
1213
(Response<()>, R)
1314
(Response<()>, T1, R)
1415
(Response<()>, T1, T2, R)
15-
(Response<()>, T1, T2, T3, R)
1616
and $N others
1717
note: required by a bound in `__axum_macros_check_handler_into_response::{closure#0}::check`
1818
--> tests/debug_handler/fail/wrong_return_type.rs:4:23

axum/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6363
- **change:** Update tokio-tungstenite to 0.19 ([#2021])
6464
- **change:** axum's MSRV is now 1.63 ([#2021])
6565
- **added:** Implement `Handler` for `T: IntoResponse` ([#2140])
66+
- **added:** Implement `IntoResponse` for `(R,) where R: IntoResponse` ([#2143])
6667

6768
[#2021]: https://github.com/tokio-rs/axum/pull/2021
6869
[#2014]: https://github.com/tokio-rs/axum/pull/2014
@@ -80,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8081
[#2073]: https://github.com/tokio-rs/axum/pull/2073
8182
[#2096]: https://github.com/tokio-rs/axum/pull/2096
8283
[#2140]: https://github.com/tokio-rs/axum/pull/2140
84+
[#2143]: https://github.com/tokio-rs/axum/pull/2143
8385

8486
# 0.6.17 (25. April, 2023)
8587

0 commit comments

Comments
 (0)