From da0c28c0b6fa73676db35f97196afd9bcfa5fa47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Raz=20Guzm=C3=A1n=20Macedo?= Date: Mon, 6 Nov 2023 11:41:47 -0600 Subject: [PATCH] use Waker::clone_from internally --- src/utils/wakers/array/readiness_array.rs | 5 ++++- src/utils/wakers/vec/readiness_vec.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/wakers/array/readiness_array.rs b/src/utils/wakers/array/readiness_array.rs index c7e2157..dd50ae7 100644 --- a/src/utils/wakers/array/readiness_array.rs +++ b/src/utils/wakers/array/readiness_array.rs @@ -62,6 +62,9 @@ impl ReadinessArray { /// Set the parent `Waker`. This needs to be called at the start of every /// `poll` function. pub(crate) fn set_waker(&mut self, parent_waker: &Waker) { - self.parent_waker = Some(parent_waker.clone()); + match &mut self.parent_waker { + Some(prev) => prev.clone_from(parent_waker), + None => self.parent_waker = Some(parent_waker.clone()), + } } } diff --git a/src/utils/wakers/vec/readiness_vec.rs b/src/utils/wakers/vec/readiness_vec.rs index 76be854..65fdc24 100644 --- a/src/utils/wakers/vec/readiness_vec.rs +++ b/src/utils/wakers/vec/readiness_vec.rs @@ -74,7 +74,10 @@ impl ReadinessVec { /// Set the parent `Waker`. This needs to be called at the start of every /// `poll` function. pub(crate) fn set_waker(&mut self, parent_waker: &Waker) { - self.parent_waker = Some(parent_waker.clone()); + match &mut self.parent_waker { + Some(prev) => prev.clone_from(parent_waker), + None => self.parent_waker = Some(parent_waker.clone()), + } } /// Resize `readiness` to the new length.