diff --git a/actix-service/src/apply.rs b/actix-service/src/apply.rs index 2a1b93f3..03b321f8 100644 --- a/actix-service/src/apply.rs +++ b/actix-service/src/apply.rs @@ -4,28 +4,31 @@ use std::marker::PhantomData; use std::pin::Pin; use std::task::{Context, Poll}; -use super::IntoFuture; use super::{Factory, IntoFactory, IntoService, Service}; /// Apply tranform function to a service -pub fn apply_fn(service: U, f: F) -> Apply +pub fn apply_fn( + service: U, + f: F, +) -> impl Service where - T: Service, - F: FnMut(In, &mut T) -> Out, - Out: IntoFuture, - Out::Error: From, + T: Service, + F: FnMut(In, &mut T) -> R, + R: Future>, U: IntoService, { Apply::new(service.into_service(), f) } /// Create factory for `apply` service. -pub fn apply_fn_factory(service: U, f: F) -> ApplyNewService +pub fn apply_fn_factory( + service: U, + f: F, +) -> impl Factory where - T: Factory, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, - Out::Error: From, + T: Factory, + F: FnMut(In, &mut T::Service) -> R + Clone, + R: Future>, U: IntoFactory, { ApplyNewService::new(service.into_factory(), f) @@ -34,25 +37,24 @@ where #[doc(hidden)] /// `Apply` service combinator #[pin_project] -pub struct Apply +struct Apply where - T: Service, + T: Service, { #[pin] service: T, f: F, - r: PhantomData<(In, Out)>, + r: PhantomData<(In, Out, R)>, } -impl Apply +impl Apply where - T: Service, - F: FnMut(In, &mut T) -> Out, - Out: IntoFuture, - Out::Error: From, + T: Service, + F: FnMut(In, &mut T) -> R, + R: Future>, { /// Create new `Apply` combinator - pub(crate) fn new(service: T, f: F) -> Self { + fn new(service: T, f: F) -> Self { Self { service, f, @@ -61,60 +63,44 @@ where } } -impl Clone for Apply +impl Service for Apply where - T: Service + Clone, - F: Clone, -{ - fn clone(&self) -> Self { - Apply { - service: self.service.clone(), - f: self.f.clone(), - r: PhantomData, - } - } -} - -impl Service for Apply -where - T: Service, - F: FnMut(In, &mut T) -> Out, - Out: IntoFuture, - Out::Error: From, + T: Service, + F: FnMut(In, &mut T) -> R, + R: Future>, { type Request = In; - type Response = Out::Item; - type Error = Out::Error; - type Future = Out::Future; + type Response = Out; + type Error = Err; + type Future = R; fn poll_ready(&mut self, ctx: &mut Context<'_>) -> Poll> { - Poll::Ready(futures::ready!(self.service.poll_ready(ctx)).map_err(|e| e.into())) + Poll::Ready(futures::ready!(self.service.poll_ready(ctx))) } fn call(&mut self, req: In) -> Self::Future { - (self.f)(req, &mut self.service).into_future() + (self.f)(req, &mut self.service) } } /// `ApplyNewService` new service combinator -pub struct ApplyNewService +struct ApplyNewService where - T: Factory, + T: Factory, { service: T, f: F, - r: PhantomData<(In, Out)>, + r: PhantomData<(R, In, Out)>, } -impl ApplyNewService +impl ApplyNewService where - T: Factory, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, - Out::Error: From, + T: Factory, + F: FnMut(In, &mut T::Service) -> R + Clone, + R: Future>, { /// Create new `ApplyNewService` new service instance - pub(crate) fn new(service: T, f: F) -> Self { + fn new(service: T, f: F) -> Self { Self { f, service, @@ -123,36 +109,20 @@ where } } -impl Clone for ApplyNewService +impl Factory for ApplyNewService where - T: Factory + Clone, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, -{ - fn clone(&self) -> Self { - Self { - service: self.service.clone(), - f: self.f.clone(), - r: PhantomData, - } - } -} - -impl Factory for ApplyNewService -where - T: Factory, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, - Out::Error: From, + T: Factory, + F: FnMut(In, &mut T::Service) -> R + Clone, + R: Future>, { type Request = In; - type Response = Out::Item; - type Error = Out::Error; + type Response = Out; + type Error = Err; type Config = T::Config; - type Service = Apply; + type Service = Apply; type InitError = T::InitError; - type Future = ApplyNewServiceFuture; + type Future = ApplyNewServiceFuture; fn new_service(&self, cfg: &T::Config) -> Self::Future { ApplyNewServiceFuture::new(self.service.new_service(cfg), self.f.clone()) @@ -160,11 +130,11 @@ where } #[pin_project] -pub struct ApplyNewServiceFuture +struct ApplyNewServiceFuture where - T: Factory, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, + T: Factory, + F: FnMut(In, &mut T::Service) -> R + Clone, + R: Future>, { #[pin] fut: T::Future, @@ -172,11 +142,11 @@ where r: PhantomData<(In, Out)>, } -impl ApplyNewServiceFuture +impl ApplyNewServiceFuture where - T: Factory, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, + T: Factory, + F: FnMut(In, &mut T::Service) -> R + Clone, + R: Future>, { fn new(fut: T::Future, f: F) -> Self { ApplyNewServiceFuture { @@ -187,14 +157,13 @@ where } } -impl Future for ApplyNewServiceFuture +impl Future for ApplyNewServiceFuture where - T: Factory, - F: FnMut(In, &mut T::Service) -> Out + Clone, - Out: IntoFuture, - Out::Error: From, + T: Factory, + F: FnMut(In, &mut T::Service) -> R + Clone, + R: Future>, { - type Output = Result, T::InitError>; + type Output = Result, T::InitError>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); diff --git a/actix-service/src/apply_cfg.rs b/actix-service/src/apply_cfg.rs index 5a79d766..cd6a62f1 100644 --- a/actix-service/src/apply_cfg.rs +++ b/actix-service/src/apply_cfg.rs @@ -7,10 +7,10 @@ use futures::ready; use pin_project::pin_project; use crate::cell::Cell; -use crate::{Factory, IntoFuture, IntoService, Service}; +use crate::{Factory, IntoService, Service}; /// Convert `Fn(&Config, &mut Service) -> Future` fn to a NewService -pub fn apply_cfg( +pub fn apply_cfg( srv: T, f: F, ) -> impl Factory< @@ -19,18 +19,17 @@ pub fn apply_cfg( Response = S::Response, Error = S::Error, Service = S, - InitError = R::Error, + InitError = E, > + Clone where F: FnMut(&C, &mut T) -> R, T: Service, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { ApplyConfigService { f: Cell::new(f), - srv: Cell::new(srv.into_service()), + srv: Cell::new(srv), _t: PhantomData, } } @@ -53,8 +52,7 @@ where F: FnMut(&C, &mut T::Service) -> R, T: Factory, T::InitError: From, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { ApplyConfigNewService { @@ -66,12 +64,11 @@ where /// Convert `Fn(&Config) -> Future` fn to NewService\ #[pin_project] -struct ApplyConfigService +struct ApplyConfigService where F: FnMut(&C, &mut T) -> R, T: Service, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { f: Cell, @@ -80,12 +77,11 @@ where _t: PhantomData<(C, R, S)>, } -impl Clone for ApplyConfigService +impl Clone for ApplyConfigService where F: FnMut(&C, &mut T) -> R, T: Service, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { fn clone(&self) -> Self { @@ -97,12 +93,11 @@ where } } -impl Factory for ApplyConfigService +impl Factory for ApplyConfigService where F: FnMut(&C, &mut T) -> R, T: Service, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { type Config = C; @@ -111,37 +106,34 @@ where type Error = S::Error; type Service = S; - type InitError = R::Error; - type Future = FnNewServiceConfigFut; + type InitError = E; + type Future = FnNewServiceConfigFut; fn new_service(&self, cfg: &C) -> Self::Future { FnNewServiceConfigFut { - fut: unsafe { (self.f.get_mut_unsafe())(cfg, self.srv.get_mut_unsafe()) } - .into_future(), + fut: unsafe { (self.f.get_mut_unsafe())(cfg, self.srv.get_mut_unsafe()) }, _t: PhantomData, } } } #[pin_project] -struct FnNewServiceConfigFut +struct FnNewServiceConfigFut where - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { #[pin] - fut: R::Future, + fut: R, _t: PhantomData<(S,)>, } -impl Future for FnNewServiceConfigFut +impl Future for FnNewServiceConfigFut where - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { - type Output = Result; + type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { Poll::Ready(Ok(ready!(self.project().fut.poll(cx))?.into_service())) @@ -154,8 +146,7 @@ where C: Clone, F: FnMut(&C, &mut T::Service) -> R, T: Factory, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { f: Cell, @@ -168,8 +159,7 @@ where C: Clone, F: FnMut(&C, &mut T::Service) -> R, T: Factory, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { fn clone(&self) -> Self { @@ -187,8 +177,7 @@ where F: FnMut(&C, &mut T::Service) -> R, T: Factory, T::InitError: From, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { type Config = C; @@ -197,7 +186,7 @@ where type Error = S::Error; type Service = S; - type InitError = R::Error; + type InitError = T::InitError; type Future = ApplyConfigNewServiceFut; fn new_service(&self, cfg: &C) -> Self::Future { @@ -219,8 +208,7 @@ where F: FnMut(&C, &mut T::Service) -> R, T: Factory, T::InitError: From, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { cfg: C, @@ -229,7 +217,7 @@ where #[pin] srv_fut: Option, #[pin] - fut: Option, + fut: Option, _t: PhantomData<(S,)>, } @@ -239,11 +227,10 @@ where F: FnMut(&C, &mut T::Service) -> R, T: Factory, T::InitError: From, - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { - type Output = Result; + type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let mut this = self.project(); @@ -264,8 +251,7 @@ where } else if let Some(ref mut srv) = this.srv { match srv.poll_ready(cx)? { Poll::Ready(_) => { - this.fut - .set(Some(this.f.get_mut()(&this.cfg, srv).into_future())); + this.fut.set(Some(this.f.get_mut()(&this.cfg, srv))); continue 'poll; } Poll::Pending => return Poll::Pending, diff --git a/actix-service/src/boxed.rs b/actix-service/src/boxed.rs index 784678a2..e93c7aa4 100644 --- a/actix-service/src/boxed.rs +++ b/actix-service/src/boxed.rs @@ -7,7 +7,7 @@ use std::task::{Context, Poll}; use futures::future::{err, ok, Either, Ready}; use futures::future::{FutureExt, LocalBoxFuture}; -use crate::{Factory, IntoFuture, Service}; +use crate::{Factory, Service}; pub type BoxedService = Box< dyn Service< diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs index 743a835b..78c73fe0 100644 --- a/actix-service/src/fn_service.rs +++ b/actix-service/src/fn_service.rs @@ -6,163 +6,154 @@ use std::task::{Context, Poll}; use futures::future::{ok, Ready}; use pin_project::pin_project; -use crate::IntoFuture; use crate::{Factory, IntoFactory, IntoService, Service}; -/// Create `NewService` for function that can act as a Service -pub fn service_fn( +/// Create `Factory` for function that can act as a Service +pub fn service_fn( f: F, -) -> impl Factory< - Config = Cfg, - Request = Req, - Response = Out::Item, - Error = Out::Error, - InitError = (), -> +) -> impl Factory + Clone where - F: FnMut(Req) -> Out + Clone, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { NewServiceFn::new(f) } /// Create `Factory` for function that can produce services -pub fn factory_fn( +pub fn service_fn_factory( f: F, ) -> impl Factory< - Config = C, + Config = Cfg, Request = S::Request, Response = S::Response, Error = S::Error, - InitError = E, - Future = R::Future, + InitError = Err, + Future = Fut, > where - F: Fn() -> R, - R: IntoFuture, - R::Item: IntoService, S: Service, + F: Fn() -> Fut, + Fut: Future>, { FnNewServiceNoConfig::new(f) } -/// Create `NewService` for function that can produce services with configuration -pub fn new_service_cfg( +/// Create `Factory` for function that can produce services with configuration +pub fn service_fn_config( f: F, ) -> impl Factory< - Config = C, - Request = S::Request, - Response = S::Response, - Error = S::Error, - InitError = E, + Config = Cfg, + Request = Srv::Request, + Response = Srv::Response, + Error = Srv::Error, + InitError = Err, > where - F: Fn(&C) -> R, - R: IntoFuture, - R::Item: IntoService, - S: Service, + F: Fn(&Cfg) -> Fut, + Fut: Future>, + Srv: Service, { FnNewServiceConfig::new(f) } -pub(crate) struct ServiceFn +pub struct ServiceFn where - F: FnMut(Req) -> Out, - Out: IntoFuture, + F: FnMut(Req) -> Fut, + Fut: Future>, { f: F, _t: PhantomData, } -impl ServiceFn +impl ServiceFn where - F: FnMut(Req) -> Out, - Out: IntoFuture, + F: FnMut(Req) -> Fut, + Fut: Future>, { pub(crate) fn new(f: F) -> Self { ServiceFn { f, _t: PhantomData } } } -impl Clone for ServiceFn +impl Clone for ServiceFn where - F: FnMut(Req) -> Out + Clone, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { fn clone(&self) -> Self { ServiceFn::new(self.f.clone()) } } -impl Service for ServiceFn +impl Service for ServiceFn where - F: FnMut(Req) -> Out, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { type Request = Req; - type Response = Out::Item; - type Error = Out::Error; - type Future = Out::Future; + type Response = Res; + type Error = Err; + type Future = Fut; fn poll_ready(&mut self, _ctx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: Req) -> Self::Future { - (self.f)(req).into_future() + (self.f)(req) } } -impl IntoService> for F +impl IntoService> for F where - F: FnMut(Req) -> Out, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { - fn into_service(self) -> ServiceFn { + fn into_service(self) -> ServiceFn { ServiceFn::new(self) } } -pub(crate) struct NewServiceFn +struct NewServiceFn where - F: FnMut(Req) -> Out, - Out: IntoFuture, + F: FnMut(Req) -> Fut, + Fut: Future>, { f: F, _t: PhantomData<(Req, Cfg)>, } -impl NewServiceFn +impl NewServiceFn where - F: FnMut(Req) -> Out + Clone, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { - pub(crate) fn new(f: F) -> Self { + fn new(f: F) -> Self { NewServiceFn { f, _t: PhantomData } } } -impl Clone for NewServiceFn +impl Clone for NewServiceFn where - F: FnMut(Req) -> Out + Clone, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { fn clone(&self) -> Self { NewServiceFn::new(self.f.clone()) } } -impl Factory for NewServiceFn +impl Factory for NewServiceFn where - F: FnMut(Req) -> Out + Clone, - Out: IntoFuture, + F: FnMut(Req) -> Fut + Clone, + Fut: Future>, { type Request = Req; - type Response = Out::Item; - type Error = Out::Error; + type Response = Res; + type Error = Err; type Config = Cfg; - type Service = ServiceFn; + type Service = ServiceFn; type InitError = (); type Future = Ready>; @@ -171,118 +162,79 @@ where } } -impl IntoService> for NewServiceFn -where - F: FnMut(Req) -> Out + Clone, - Out: IntoFuture, -{ - fn into_service(self) -> ServiceFn { - ServiceFn::new(self.f.clone()) - } -} - -impl IntoFactory> for F -where - F: Fn(Req) -> Out + Clone, - Out: IntoFuture, -{ - fn into_factory(self) -> NewServiceFn { - NewServiceFn::new(self) - } -} - /// Convert `Fn(&Config) -> Future` fn to NewService -pub(crate) struct FnNewServiceConfig +struct FnNewServiceConfig where - F: Fn(&C) -> R, - R: IntoFuture, - R::Item: IntoService, - S: Service, + F: Fn(&Cfg) -> Fut, + Fut: Future>, + Srv: Service, { f: F, - _t: PhantomData<(C, R, S, E)>, + _t: PhantomData<(Fut, Cfg, Srv, Err)>, } -impl FnNewServiceConfig +impl FnNewServiceConfig where - F: Fn(&C) -> R, - R: IntoFuture, - R::Item: IntoService, - S: Service, + F: Fn(&Cfg) -> Fut, + Fut: Future>, + Srv: Service, { pub fn new(f: F) -> Self { FnNewServiceConfig { f, _t: PhantomData } } } -impl Factory for FnNewServiceConfig +impl Factory for FnNewServiceConfig where - F: Fn(&C) -> R, - R: IntoFuture, - R::Item: IntoService, - S: Service, + F: Fn(&Cfg) -> Fut, + Fut: Future>, + Srv: Service, { - type Request = S::Request; - type Response = S::Response; - type Error = S::Error; + type Request = Srv::Request; + type Response = Srv::Response; + type Error = Srv::Error; - type Config = C; - type Service = S; - type InitError = E; - type Future = FnNewServiceConfigFut; + type Config = Cfg; + type Service = Srv; + type InitError = Err; + type Future = FnNewServiceConfigFut; - fn new_service(&self, cfg: &C) -> Self::Future { + fn new_service(&self, cfg: &Cfg) -> Self::Future { FnNewServiceConfigFut { - fut: (self.f)(cfg).into_future(), + fut: (self.f)(cfg), _t: PhantomData, } } } #[pin_project] -pub(crate) struct FnNewServiceConfigFut +struct FnNewServiceConfigFut where - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { #[pin] - fut: R::Future, + fut: R, _t: PhantomData<(S,)>, } impl Future for FnNewServiceConfigFut where - R: IntoFuture, - R::Item: IntoService, + R: Future>, S: Service, { - type Output = Result; + type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - Poll::Ready(Ok( - futures::ready!(self.project().fut.poll(cx))?.into_service() - )) - } -} - -impl Clone for FnNewServiceConfig -where - F: Fn(&C) -> R + Clone, - R: IntoFuture, - R::Item: IntoService, - S: Service, -{ - fn clone(&self) -> Self { - Self::new(self.f.clone()) + Poll::Ready(Ok(futures::ready!(self.project().fut.poll(cx))?)) } } /// Converter for `Fn() -> Future` fn -pub(crate) struct FnNewServiceNoConfig +pub struct FnNewServiceNoConfig where F: Fn() -> R, - R: IntoFuture, + R: Future>, S: Service, { f: F, @@ -292,10 +244,10 @@ where impl FnNewServiceNoConfig where F: Fn() -> R, - R: IntoFuture, + R: Future>, S: Service, { - pub fn new(f: F) -> Self { + fn new(f: F) -> Self { FnNewServiceNoConfig { f, _t: PhantomData } } } @@ -303,7 +255,7 @@ where impl Factory for FnNewServiceNoConfig where F: Fn() -> R, - R: IntoFuture, + R: Future>, S: Service, { type Request = S::Request; @@ -312,17 +264,17 @@ where type Service = S; type Config = C; type InitError = E; - type Future = R::Future; + type Future = R; fn new_service(&self, _: &C) -> Self::Future { - (self.f)().into_future() + (self.f)() } } impl Clone for FnNewServiceNoConfig where F: Fn() -> R + Clone, - R: IntoFuture, + R: Future>, S: Service, { fn clone(&self) -> Self { @@ -333,7 +285,7 @@ where impl IntoFactory> for F where F: Fn() -> R, - R: IntoFuture, + R: Future>, S: Service, { fn into_factory(self) -> FnNewServiceNoConfig { diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index db5673f7..a79f6ebe 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -22,29 +22,12 @@ mod transform_err; pub use self::apply::{apply_fn, apply_fn_factory}; pub use self::apply_cfg::{apply_cfg, apply_cfg_factory}; -pub use self::fn_service::{factory_fn, new_service_cfg, service_fn}; +pub use self::fn_service::{service_fn, service_fn_config, service_fn_factory}; pub use self::into::{into_factory, into_service, FactoryMapper, ServiceMapper}; pub use self::map_config::{map_config, unit_config, MappedConfig}; pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory}; pub use self::transform::{apply_transform, IntoTransform, Transform}; -pub trait IntoFuture { - type Item; - type Error; - type Future: Future>; - fn into_future(self) -> Self::Future; -} - -impl>, I, E> IntoFuture for F { - type Item = I; - type Error = E; - type Future = F; - - fn into_future(self) -> Self::Future { - self - } -} - /// An asynchronous function from `Request` to a `Response`. pub trait Service { /// Requests handled by the service. @@ -80,31 +63,6 @@ pub trait Service { /// Calling `call` without calling `poll_ready` is permitted. The /// implementation must be resilient to this fact. fn call(&mut self, req: Self::Request) -> Self::Future; - - // #[cfg(test)] - // fn poll_test(&mut self) -> Poll> { - // // kinda stupid method, but works for our test purposes - // unsafe { - // let mut this = Pin::new_unchecked(self); - // tokio::runtime::current_thread::Builder::new() - // .build() - // .unwrap() - // .block_on(futures::future::poll_fn(move |cx| { - // let this = &mut this; - // Poll::Ready(this.as_mut().poll_ready(cx)) - // })) - // } - // } - - // fn poll_once<'a>(&'a mut self) -> LocalBoxFuture<'a, Poll>> { - // unsafe { - // let mut this = Pin::new_unchecked(self); - // Pin::new_unchecked(Box::new(futures::future::poll_fn(move |cx| { - // //let this = &mut this; - // Poll::Ready(this.get_unchecked_mut().poll_ready(cx)) - // }))) - // } - // } } /// Creates new `Service` values. @@ -243,7 +201,7 @@ where fn into_service(self) -> T; } -/// Trait for types that can be converted to a `ServiceFactory` +/// Trait for types that can be converted to a `Factory` pub trait IntoFactory where T: Factory, diff --git a/actix-service/src/map_config.rs b/actix-service/src/map_config.rs index 912a30bd..e1cfbecc 100644 --- a/actix-service/src/map_config.rs +++ b/actix-service/src/map_config.rs @@ -9,7 +9,7 @@ pub enum MappedConfig<'a, T> { /// Adapt external config to a config for provided new service pub fn map_config( - new_service: T, + factory: T, f: F, ) -> impl Factory< Config = C, @@ -22,7 +22,7 @@ where T: Factory, F: Fn(&C) -> MappedConfig, { - MapConfig::new(new_service, f) + MapConfig::new(factory, f) } /// Replace config with unit