diff --git a/src/service/make.rs b/src/service/make.rs index 56d30f10b3..490992e118 100644 --- a/src/service/make.rs +++ b/src/service/make.rs @@ -15,7 +15,6 @@ pub trait MakeConnection: self::sealed::Sealed<(Target,)> { type Future: Future>; fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll>; - fn make_connection(&mut self, target: Target) -> Self::Future; } @@ -144,7 +143,8 @@ where MakeServiceFn { f } } -// Not exported from crate as this will likely be replaced with `impl Service`. +/// `MakeService` returned from [`make_service_fn`] +#[derive(Clone, Copy)] pub struct MakeServiceFn { f: F, } diff --git a/src/service/util.rs b/src/service/util.rs index 0860fbade7..be597f7a02 100644 --- a/src/service/util.rs +++ b/src/service/util.rs @@ -35,7 +35,7 @@ where } } -// Not exported from crate as this will likely be replaced with `impl Service`. +/// Service returned by [`service_fn`] pub struct ServiceFn { f: F, _req: PhantomData, @@ -68,3 +68,17 @@ impl fmt::Debug for ServiceFn { f.debug_struct("impl Service").finish() } } + +impl Clone for ServiceFn +where + F: Clone, +{ + fn clone(&self) -> Self { + ServiceFn { + f: self.f.clone(), + _req: PhantomData, + } + } +} + +impl Copy for ServiceFn where F: Copy {}