diff --git a/src/service/http/initializer/any.rs b/src/service/http/initializer/any.rs index cef4a03e..50be7c94 100644 --- a/src/service/http/initializer/any.rs +++ b/src/service/http/initializer/any.rs @@ -5,6 +5,8 @@ use axum::Router; use axum_core::extract::FromRef; use typed_builder::TypedBuilder; +type ApplyFn = Box RoadsterResult + Send>; + #[derive(TypedBuilder)] pub struct AnyInitializer where @@ -20,7 +22,7 @@ where #[builder(default, setter(strip_option))] stage: Option, #[builder(setter(transform = |a: impl Fn(Router, &S) -> RoadsterResult + Send + 'static| to_box_fn(a) ))] - apply: Box RoadsterResult + Send>, + apply: ApplyFn, } #[derive(Default)] @@ -33,9 +35,7 @@ pub enum Stage { BeforeServe, } -fn to_box_fn( - p: impl Fn(Router, &S) -> RoadsterResult + Send + 'static, -) -> Box RoadsterResult + Send> { +fn to_box_fn(p: impl Fn(Router, &S) -> RoadsterResult + Send + 'static) -> ApplyFn { Box::new(p) } diff --git a/src/service/http/middleware/any.rs b/src/service/http/middleware/any.rs index d40d0124..1469c248 100644 --- a/src/service/http/middleware/any.rs +++ b/src/service/http/middleware/any.rs @@ -5,6 +5,8 @@ use axum::Router; use axum_core::extract::FromRef; use typed_builder::TypedBuilder; +type ApplyFn = Box RoadsterResult + Send>; + #[derive(TypedBuilder)] #[non_exhaustive] pub struct AnyMiddleware @@ -19,12 +21,10 @@ where #[builder(default, setter(strip_option))] priority: Option, #[builder(setter(transform = |a: impl Fn(Router, &S) -> RoadsterResult + Send + 'static| to_box_fn(a) ))] - apply: Box RoadsterResult + Send>, + apply: ApplyFn, } -fn to_box_fn( - p: impl Fn(Router, &S) -> RoadsterResult + Send + 'static, -) -> Box RoadsterResult + Send> { +fn to_box_fn(p: impl Fn(Router, &S) -> RoadsterResult + Send + 'static) -> ApplyFn { Box::new(p) }