From a732988ca21b54ccc16d101949fcd69d72c73837 Mon Sep 17 00:00:00 2001 From: SOFe Date: Sun, 22 Dec 2019 15:50:00 +0800 Subject: [PATCH] Implement Body for Cow<'static, str> --- actix-http/src/body.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)