Skip to content

Commit 3449d3d

Browse files
authored
feat: impl From<&'static [u8]> for Body (#1144)
In warp 0.3 there was a convenient converter from a static byte slice to response body. Since warp 0.4 has sucn converters for `String`, `&str`, and `Vec<u8>`, I think it would be reasonable to have such a converter for `&[u8]` as well.
1 parent dbb0d33 commit 3449d3d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/bodyt.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ impl From<String> for Body {
9292
}
9393
}
9494

95+
impl From<&'static [u8]> for Body {
96+
fn from(v: &'static [u8]) -> Self {
97+
Bytes::from(v).into()
98+
}
99+
}
100+
95101
impl From<Vec<u8>> for Body {
96102
fn from(v: Vec<u8>) -> Self {
97103
Bytes::from(v).into()

0 commit comments

Comments
 (0)