Skip to content

Commit

Permalink
Do not require Clone for Shared::peek (#2662)
Browse files Browse the repository at this point in the history
Makes it easier to write some generic code for wrappers of `Shared`
future: no need to properly specify all type parameters.
  • Loading branch information
stepancheg authored and taiki-e committed Jan 30, 2023
1 parent 0473f38 commit 3fa8b29
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions futures-util/src/future/future/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ impl<Fut: Future> Shared<Fut> {
impl<Fut> Shared<Fut>
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
Expand Down Expand Up @@ -160,7 +159,6 @@ where
impl<Fut> Inner<Fut>
where
Fut: Future,
Fut::Output: Clone,
{
/// Safety: callers must first ensure that `self.inner.state`
/// is `COMPLETE`
Expand All @@ -170,6 +168,13 @@ where
FutureOrOutput::Future(_) => unreachable!(),
}
}
}

impl<Fut> Inner<Fut>
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();
Expand Down

0 comments on commit 3fa8b29

Please sign in to comment.