Improve compile times of handle_error and check_infallible (#198)

* Improve compile times of `handle_error`

This brings the compile time of the example posted [here][example] from
3 seconds down to 0.3 seconds for me.

Having the bounds on the methods does improve UX but not worth
sacrificing 10x compile time for.

[example]: https://github.com/tokio-rs/axum/issues/145#issue-963183256

* Improve compile time of `check_infallible`

* update changelog
This commit is contained in:
David Pedersen
2021-08-17 19:07:47 +02:00
committed by GitHub
parent 93cdfe8c5f
commit dd0c345040
3 changed files with 39 additions and 22 deletions
+2 -7
View File
@@ -453,15 +453,10 @@ impl<S, F, B> OnMethod<S, F, B> {
/// details.
///
/// [`RoutingDsl::handle_error`]: crate::routing::RoutingDsl::handle_error
pub fn handle_error<ReqBody, H, Res, E>(
pub fn handle_error<ReqBody, H>(
self,
f: H,
) -> HandleError<Self, H, ReqBody, HandleErrorFromService>
where
Self: Service<Request<ReqBody>, Response = Response<BoxBody>>,
H: FnOnce(<Self as Service<Request<ReqBody>>>::Error) -> Result<Res, E>,
Res: IntoResponse,
{
) -> HandleError<Self, H, ReqBody, HandleErrorFromService> {
HandleError::new(self, f)
}
}