1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-04-10 11:54:06 +00:00

Implement Body for Cow<'static, str>

This commit is contained in:
SOFe 2019-12-22 15:50:00 +08:00
parent f45db1f909
commit a732988ca2
No known key found for this signature in database
GPG key ID: 6606A3CFCC04EC70

View file

@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{Context, Poll};
@ -233,6 +234,15 @@ impl<'a> From<&'a String> for Body {
}
}
impl From<Cow<'static, str>> for Body {
fn from(s: Cow<'static, str>) -> Body {
match s {
Cow::Borrowed(s) => Body::from(s),
Cow::Owned(s) => Body::from(s),
}
}
}
impl From<Bytes> for Body {
fn from(s: Bytes) -> Body {
Body::Bytes(s)