From ac9d5c32f7673c05f908fa3c54925b0d92ad094e Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Tue, 7 Dec 2021 20:00:14 +0800 Subject: [PATCH] add type bound to App::wrap and wrap_fn --- src/app.rs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/app.rs b/src/app.rs index 99c1c2586..ab2081c18 100644 --- a/src/app.rs +++ b/src/app.rs @@ -51,10 +51,7 @@ impl App { } } -impl App -where - T: ServiceFactory, -{ +impl App { /// Set application (root level) data. /// /// Application data stored with `App::app_data()` method is available through the @@ -353,7 +350,7 @@ where /// .route("/index.html", web::get().to(index)); /// } /// ``` - pub fn wrap( + pub fn wrap( self, mw: M, ) -> App< @@ -366,6 +363,14 @@ where >, > where + T: ServiceFactory< + ServiceRequest, + Response = ServiceResponse, + Error = Error, + Config = (), + InitError = (), + >, + B: MessageBody, M: Transform< T::Service, ServiceRequest, @@ -373,6 +378,7 @@ where Error = Error, InitError = (), >, + B1: MessageBody, { App { endpoint: apply(mw, self.endpoint), @@ -416,7 +422,7 @@ where /// .route("/index.html", web::get().to(index)); /// } /// ``` - pub fn wrap_fn( + pub fn wrap_fn( self, mw: F, ) -> App< @@ -429,9 +435,17 @@ where >, > where - B1: MessageBody, + T: ServiceFactory< + ServiceRequest, + Response = ServiceResponse, + Error = Error, + Config = (), + InitError = (), + >, + B: MessageBody, F: Fn(ServiceRequest, &T::Service) -> R + Clone, R: Future, Error>>, + B1: MessageBody, { App { endpoint: apply_fn_factory(self.endpoint, mw),