mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
clean up allocations
This commit is contained in:
@@ -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>,
|
||||
>;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user