diff --git a/actix-http/src/body.rs b/actix-http/src/body.rs index 850f97ee4..c6c3b852e 100644 --- a/actix-http/src/body.rs +++ b/actix-http/src/body.rs @@ -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> 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 for Body { fn from(s: Bytes) -> Body { Body::Bytes(s)