From 6b4010892d40fc15eed0f48a5f556f4316661074 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 22 Feb 2019 14:19:43 -0800 Subject: [PATCH] add IntoNewService for FnNewService --- actix-service/src/fn_service.rs | 30 ++++++++++++++++++++---------- actix-service/src/map_err.rs | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs index ec2292b5..adf13e3f 100644 --- a/actix-service/src/fn_service.rs +++ b/actix-service/src/fn_service.rs @@ -142,6 +142,16 @@ where } } +impl IntoNewService, Cfg> for F +where + F: Fn(Req) -> Out + Clone, + Out: IntoFuture, +{ + fn into_new_service(self) -> FnNewService { + FnNewService::new(self) + } +} + /// Converter for `Fn() -> Future` fn pub struct FnNewServiceNoConfig where @@ -256,13 +266,13 @@ where } } -impl IntoNewService, C> for F -where - F: Fn(&C) -> R, - R: IntoFuture, - S: Service, -{ - fn into_new_service(self) -> FnNewServiceConfig { - FnNewServiceConfig::new(self) - } -} +// impl IntoNewService, C> for F +// where +// F: Fn(&C) -> R, +// R: IntoFuture, +// S: Service, +// { +// fn into_new_service(self) -> FnNewServiceConfig { +// FnNewServiceConfig::new(self) +// } +// } diff --git a/actix-service/src/map_err.rs b/actix-service/src/map_err.rs index 4e519976..cd15d239 100644 --- a/actix-service/src/map_err.rs +++ b/actix-service/src/map_err.rs @@ -229,7 +229,7 @@ mod tests { #[test] fn test_new_service() { - let blank = |_: &()| Ok::<_, ()>(Srv); + let blank = || Ok::<_, ()>(Srv); let new_srv = blank.into_new_service().map_err(|_| "error"); if let Async::Ready(mut srv) = new_srv.new_service(&()).poll().unwrap() { let res = srv.call(()).poll();