From 7dec5c064b73fce712b0810c261d99f6cbb01ef4 Mon Sep 17 00:00:00 2001 From: Alexander van Ratingen <470642+alvra@users.noreply.github.com> Date: Mon, 26 Jun 2023 13:14:28 +0200 Subject: [PATCH] Implement `IntoResponse` for boxed slices (#2035) --- axum-core/src/response/into_response.rs | 12 ++++++++++++ axum/CHANGELOG.md | 1 + 2 files changed, 13 insertions(+) diff --git a/axum-core/src/response/into_response.rs b/axum-core/src/response/into_response.rs index f19974cfb7..898252a2e3 100644 --- a/axum-core/src/response/into_response.rs +++ b/axum-core/src/response/into_response.rs @@ -241,6 +241,12 @@ impl IntoResponse for String { } } +impl IntoResponse for Box { + fn into_response(self) -> Response { + String::from(self).into_response() + } +} + impl IntoResponse for Cow<'static, str> { fn into_response(self) -> Response { let mut res = Full::from(self).into_response(); @@ -366,6 +372,12 @@ impl IntoResponse for Vec { } } +impl IntoResponse for Box<[u8]> { + fn into_response(self) -> Response { + Vec::from(self).into_response() + } +} + impl IntoResponse for Cow<'static, [u8]> { fn into_response(self) -> Response { let mut res = Full::from(self).into_response(); diff --git a/axum/CHANGELOG.md b/axum/CHANGELOG.md index 9eec180cf4..33f45d4727 100644 --- a/axum/CHANGELOG.md +++ b/axum/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # 0.6.18 (30. April, 2023) - **fixed:** Don't remove the `Sec-WebSocket-Key` header in `WebSocketUpgrade` ([#1972]) +- **added:** Implement `IntoResponse` for `Box` and `Box<[u8]>` ([#2035]) [#1972]: https://github.com/tokio-rs/axum/pull/1972