clean up allocations

This commit is contained in:
David Pedersen
2022-03-13 16:35:46 +01:00
parent 6309e7043c
commit 630287f76a
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -1,14 +1,14 @@
//! Handler future types.
use crate::response::Response;
use futures_util::future::{BoxFuture, Map};
use futures_util::future::Map;
use std::convert::Infallible;
opaque_future! {
/// The response future for [`IntoService`](super::IntoService).
pub type IntoServiceFuture =
pub type IntoServiceFuture<F> =
Map<
BoxFuture<'static, Response>,
F,
fn(Response) -> Result<Response, Infallible>,
>;
}
+4 -4
View File
@@ -60,7 +60,7 @@ where
{
type Response = Response;
type Error = Infallible;
type Future = super::future::IntoServiceFuture;
type Future = super::future::IntoServiceFuture<H::Future>;
#[inline]
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
@@ -71,11 +71,11 @@ where
}
fn call(&mut self, req: Request<B>) -> Self::Future {
use futures_util::future::{BoxFuture, FutureExt};
use futures_util::future::FutureExt;
let handler = self.handler.clone();
let future = Box::pin(Handler::call(handler, req)) as BoxFuture<'static, _>;
let future = future.map(Ok::<_, Infallible> as _);
let future = Handler::call(handler, req);
let future = future.map(Ok as _);
super::future::IntoServiceFuture::new(future)
}