Implement From<S> for StreamBody<S> (#866)

Although this shadows `StreamBody::new()`, having `From` allows for
trivial bounds creation on associated types.

Signed-off-by: Nathaniel McCallum <[email protected]>
This commit is contained in:
Nathaniel McCallum
2022-03-18 15:40:27 +00:00
committed by GitHub
parent a0ae0c48aa
commit 30b2cf8f96
+11
View File
@@ -57,6 +57,17 @@ pin_project! {
}
}
impl<S> From<S> for StreamBody<S>
where
S: TryStream + Send + 'static,
S::Ok: Into<Bytes>,
S::Error: Into<BoxError>,
{
fn from(stream: S) -> Self {
Self::new(stream)
}
}
impl<S> StreamBody<S> {
/// Create a new `StreamBody` from a [`Stream`].
///