Skip to content

Commit

Permalink
Implement IntoResponse for boxed slices (#2035)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvra authored and davidpdrsn committed Jul 16, 2023
1 parent 357adb0 commit 7dec5c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions axum-core/src/response/into_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ impl IntoResponse for String {
}
}

impl IntoResponse for Box<str> {
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();
Expand Down Expand Up @@ -366,6 +372,12 @@ impl IntoResponse for Vec<u8> {
}
}

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();
Expand Down
1 change: 1 addition & 0 deletions axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<str>` and `Box<[u8]>` ([#2035])

[#1972]: https://github.com/tokio-rs/axum/pull/1972

Expand Down

0 comments on commit 7dec5c0

Please sign in to comment.