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 <nathaniel@profian.com>
This commit is contained in:
Nathaniel McCallum 2022-03-18 11:40:27 -04:00 committed by GitHub
parent a0ae0c48aa
commit 30b2cf8f96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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`].
///