diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index e591eb51..66132961 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -150,6 +150,7 @@ pub trait ServiceFactory { fn new_service(&self, cfg: Self::Config) -> Self::Future; } +// TODO: remove implement on mut reference. impl<'a, S, Req> Service for &'a mut S where S: Service + 'a, @@ -167,6 +168,23 @@ where } } +impl<'a, S, Req> Service for &'a S +where + S: Service + 'a, +{ + type Response = S::Response; + type Error = S::Error; + type Future = S::Future; + + fn poll_ready(&self, ctx: &mut Context<'_>) -> Poll> { + (**self).poll_ready(ctx) + } + + fn call(&self, request: Req) -> S::Future { + (**self).call(request) + } +} + impl Service for Box where S: Service + ?Sized, @@ -184,7 +202,7 @@ where } } -impl Service for RefCell +impl Service for Rc where S: Service, { @@ -193,15 +211,15 @@ where type Future = S::Future; fn poll_ready(&self, ctx: &mut Context<'_>) -> Poll> { - self.borrow().poll_ready(ctx) + (&**self).poll_ready(ctx) } fn call(&self, request: Req) -> S::Future { - self.borrow().call(request) + (&**self).call(request) } } -impl Service for Rc> +impl Service for RefCell where S: Service, {