From a15a165979b8bec0f563931926c82278bf7b9006 Mon Sep 17 00:00:00 2001 From: Stiopa Koltsov Date: Sun, 30 Oct 2022 16:31:57 +0000 Subject: [PATCH] Do not require Clone for Shared::peek Makes it easier to write some generic code for wrappers of `Shared` future: no need to properly specify all type parameters. --- futures-util/src/future/future/shared.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/futures-util/src/future/future/shared.rs b/futures-util/src/future/future/shared.rs index dd7c2f5067..6d558aa587 100644 --- a/futures-util/src/future/future/shared.rs +++ b/futures-util/src/future/future/shared.rs @@ -103,7 +103,6 @@ impl Shared { impl Shared where Fut: Future, - Fut::Output: Clone, { /// Returns [`Some`] containing a reference to this [`Shared`]'s output if /// it has already been computed by a clone or [`None`] if it hasn't been @@ -160,7 +159,6 @@ where impl Inner where Fut: Future, - Fut::Output: Clone, { /// Safety: callers must first ensure that `self.inner.state` /// is `COMPLETE` @@ -170,6 +168,13 @@ where FutureOrOutput::Future(_) => unreachable!(), } } +} + +impl Inner +where + Fut: Future, + Fut::Output: Clone, +{ /// Registers the current task to receive a wakeup when we are awoken. fn record_waker(&self, waker_key: &mut usize, cx: &mut Context<'_>) { let mut wakers_guard = self.notifier.wakers.lock().unwrap();