From 028279713eea66b7550330807872498d70636986 Mon Sep 17 00:00:00 2001 From: Nikolay Kim <fafhrd91@gmail.com> Date: Tue, 2 Oct 2018 21:31:11 -0700 Subject: [PATCH] simplify FnNewService --- src/service/fn_service.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/service/fn_service.rs b/src/service/fn_service.rs index 7a4e2284..e81ca642 100644 --- a/src/service/fn_service.rs +++ b/src/service/fn_service.rs @@ -71,16 +71,16 @@ where } } -pub struct FnNewService<F, Req, Resp, Err, IErr, Fut> +pub struct FnNewService<F, Req, Resp, Err, Fut> where F: Fn(Req) -> Fut, Fut: IntoFuture<Item = Resp, Error = Err>, { f: F, - _t: marker::PhantomData<(Req, Resp, Err, IErr)>, + _t: marker::PhantomData<(Req, Resp, Err)>, } -impl<F, Req, Resp, Err, IErr, Fut> FnNewService<F, Req, Resp, Err, IErr, Fut> +impl<F, Req, Resp, Err, Fut> FnNewService<F, Req, Resp, Err, Fut> where F: Fn(Req) -> Fut + Clone, Fut: IntoFuture<Item = Resp, Error = Err>, @@ -93,7 +93,7 @@ where } } -impl<F, Req, Resp, Err, IErr, Fut> NewService for FnNewService<F, Req, Resp, Err, IErr, Fut> +impl<F, Req, Resp, Err, Fut> NewService for FnNewService<F, Req, Resp, Err, Fut> where F: Fn(Req) -> Fut + Clone, Fut: IntoFuture<Item = Resp, Error = Err>, @@ -102,7 +102,7 @@ where type Response = Resp; type Error = Err; type Service = FnService<F, Req, Resp, Err, Fut>; - type InitError = IErr; + type InitError = (); type Future = FutureResult<Self::Service, Self::InitError>; fn new_service(&self) -> Self::Future { @@ -110,18 +110,17 @@ where } } -impl<F, Req, Resp, Err, IErr, Fut> IntoNewService<FnNewService<F, Req, Resp, Err, IErr, Fut>> - for F +impl<F, Req, Resp, Err, Fut> IntoNewService<FnNewService<F, Req, Resp, Err, Fut>> for F where F: Fn(Req) -> Fut + Clone + 'static, Fut: IntoFuture<Item = Resp, Error = Err>, { - fn into_new_service(self) -> FnNewService<F, Req, Resp, Err, IErr, Fut> { + fn into_new_service(self) -> FnNewService<F, Req, Resp, Err, Fut> { FnNewService::new(self) } } -impl<F, Req, Resp, Err, IErr, Fut> Clone for FnNewService<F, Req, Resp, Err, IErr, Fut> +impl<F, Req, Resp, Err, Fut> Clone for FnNewService<F, Req, Resp, Err, Fut> where F: Fn(Req) -> Fut + Clone, Fut: IntoFuture<Item = Resp, Error = Err>,