async: Add conversions from static slices to Body
These useful conversions were missed in #159. refs #158
This commit is contained in:
		| @@ -51,6 +51,13 @@ impl From<Vec<u8>> for Body { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | impl From<&'static [u8]> for Body { | ||||||
|  |     #[inline] | ||||||
|  |     fn from(s: &'static [u8]) -> Body { | ||||||
|  |         reusable(Bytes::from_static(s)) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| impl From<String> for Body { | impl From<String> for Body { | ||||||
|     #[inline] |     #[inline] | ||||||
|     fn from(s: String) -> Body { |     fn from(s: String) -> Body { | ||||||
| @@ -58,6 +65,13 @@ impl From<String> for Body { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | impl From<&'static str> for Body { | ||||||
|  |     #[inline] | ||||||
|  |     fn from(s: &'static str) -> Body { | ||||||
|  |         s.as_bytes().into() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| /// A chunk of bytes for a `Body`. | /// A chunk of bytes for a `Body`. | ||||||
| /// | /// | ||||||
| /// A `Chunk` can be treated like `&[u8]`. | /// A `Chunk` can be treated like `&[u8]`. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user