From 3fa8b295dd2dd3e2ac7b27ce2176d745797a22a2 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 2 Nov 2022 05:46:33 +0000 Subject: [PATCH] Do not require Clone for Shared::peek (#2662) 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 985931564..e1ffb32c9 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();