diff --git a/axum/src/handler/future.rs b/axum/src/handler/future.rs index 6bd39b35..d126dd76 100644 --- a/axum/src/handler/future.rs +++ b/axum/src/handler/future.rs @@ -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 = Map< - BoxFuture<'static, Response>, + F, fn(Response) -> Result, >; } diff --git a/axum/src/handler/into_service.rs b/axum/src/handler/into_service.rs index bb99d57f..34f36b2d 100644 --- a/axum/src/handler/into_service.rs +++ b/axum/src/handler/into_service.rs @@ -60,7 +60,7 @@ where { type Response = Response; type Error = Infallible; - type Future = super::future::IntoServiceFuture; + type Future = super::future::IntoServiceFuture; #[inline] fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { @@ -71,11 +71,11 @@ where } fn call(&mut self, req: Request) -> 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) }