Skip to content

Commit c3c35e8

Browse files
lnicolaseanmonstar
authored andcommitted
perf(body): avoid boxing Streams twice
1 parent bc6af88 commit c3c35e8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/body.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,17 @@ impl From<Chunk> for Body {
421421
}
422422
}
423423

424-
impl<S> From<Box<S>> for Body
425-
where
426-
S: Stream + Send + 'static,
427-
S::Error: Into<Box<::std::error::Error + Send + Sync>>,
428-
Chunk: From<S::Item>,
424+
impl
425+
From<Box<Stream<Item = Chunk, Error = Box<::std::error::Error + Send + Sync>> + Send + 'static>>
426+
for Body
429427
{
430428
#[inline]
431-
fn from(stream: Box<S>) -> Body {
432-
Body::wrap_stream(stream)
429+
fn from(
430+
stream: Box<
431+
Stream<Item = Chunk, Error = Box<::std::error::Error + Send + Sync>> + Send + 'static,
432+
>,
433+
) -> Body {
434+
Body::new(Kind::Wrapped(stream))
433435
}
434436
}
435437

0 commit comments

Comments
 (0)