From 30b2cf8f960bcb992f87aff743778655eb4a71a1 Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Fri, 18 Mar 2022 11:40:27 -0400 Subject: [PATCH] Implement From for StreamBody (#866) Although this shadows `StreamBody::new()`, having `From` allows for trivial bounds creation on associated types. Signed-off-by: Nathaniel McCallum --- axum/src/body/stream_body.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/axum/src/body/stream_body.rs b/axum/src/body/stream_body.rs index 6c04ce81..89758ed3 100644 --- a/axum/src/body/stream_body.rs +++ b/axum/src/body/stream_body.rs @@ -57,6 +57,17 @@ pin_project! { } } +impl From for StreamBody +where + S: TryStream + Send + 'static, + S::Ok: Into, + S::Error: Into, +{ + fn from(stream: S) -> Self { + Self::new(stream) + } +} + impl StreamBody { /// Create a new `StreamBody` from a [`Stream`]. ///