use boxed trait method where appropriate

This commit is contained in:
Rob Ede 2021-12-17 00:09:11 +00:00
parent 88a1999c06
commit 240c85260b
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
4 changed files with 4 additions and 7 deletions

View File

@ -194,7 +194,7 @@ impl<B> Response<B> {
where
B: MessageBody + 'static,
{
self.map_body(|_, body| BoxBody::new(body))
self.map_body(|_, body| body.boxed())
}
/// Returns body, consuming this response.

View File

@ -45,9 +45,7 @@ impl AnyBody {
where
B: MessageBody + 'static,
{
Self::Body {
body: BoxBody::new(body),
}
Self::Body { body: body.boxed() }
}
/// Constructs new `AnyBody` instance from a slice of bytes by copying it.

View File

@ -244,8 +244,7 @@ impl<B> HttpResponse<B> {
where
B: MessageBody + 'static,
{
// TODO: avoid double boxing with down-casting, if it improves perf
self.map_body(|_, body| BoxBody::new(body))
self.map_body(|_, body| body.boxed())
}
/// Extract response body

View File

@ -451,7 +451,7 @@ impl<B> ServiceResponse<B> {
where
B: MessageBody + 'static,
{
self.map_body(|_, body| BoxBody::new(body))
self.map_body(|_, body| body.boxed())
}
}