Implement IntoResponse for [u8; N] and &'static [u8; N] (#1690)

Co-authored-by: David Pedersen <[email protected]>
This commit is contained in:
valkyrie_pilot
2023-01-13 09:12:51 +00:00
committed by GitHub
co-authored by David Pedersen
parent e3aaeb3cb7
commit e4c6d76bca
4 changed files with 46 additions and 30 deletions
+12
View File
@@ -348,6 +348,18 @@ impl IntoResponse for &'static [u8] {
}
}
impl<const N: usize> IntoResponse for &'static [u8; N] {
fn into_response(self) -> Response {
self.as_slice().into_response()
}
}
impl<const N: usize> IntoResponse for [u8; N] {
fn into_response(self) -> Response {
self.to_vec().into_response()
}
}
impl IntoResponse for Vec<u8> {
fn into_response(self) -> Response {
Cow::<'static, [u8]>::Owned(self).into_response()