From 9ef954f00ed7d77f44d3ae20c005478bc322767c Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Fri, 25 Mar 2022 15:51:13 +0000 Subject: [PATCH] Stream selection passes PollNext by value internally --- .../src/stream/select_with_strategy.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/futures-util/src/stream/select_with_strategy.rs b/futures-util/src/stream/select_with_strategy.rs index ca7b5dad12..37dc5fe338 100644 --- a/futures-util/src/stream/select_with_strategy.rs +++ b/futures-util/src/stream/select_with_strategy.rs @@ -44,7 +44,7 @@ enum InternalState { } impl InternalState { - fn finish(&mut self, ps: &PollNext) { + fn finish(&mut self, ps: PollNext) { match (&self, ps) { (InternalState::Start, PollNext::Left) => { *self = InternalState::LeftFinished; @@ -209,7 +209,7 @@ where #[inline] fn poll_side( select: &mut SelectWithStrategyProj<'_, St1, St2, Clos, State>, - side: &PollNext, + side: PollNext, cx: &mut Context<'_>, ) -> Poll> where @@ -225,7 +225,7 @@ where #[inline] fn poll_inner( select: &mut SelectWithStrategyProj<'_, St1, St2, Clos, State>, - side: &PollNext, + side: PollNext, cx: &mut Context<'_>, ) -> Poll> where @@ -240,9 +240,9 @@ where Poll::Pending => (), }; let other = side.other(); - match poll_side(select, &other, cx) { + match poll_side(select, other, cx) { Poll::Ready(None) => { - select.internal_state.finish(&other); + select.internal_state.finish(other); Poll::Ready(None) } a => a, @@ -261,10 +261,10 @@ where let mut this = self.project(); match this.internal_state { - InternalState::Start => match (this.clos)(this.state) { - PollNext::Left => poll_inner(&mut this, &PollNext::Left, cx), - PollNext::Right => poll_inner(&mut this, &PollNext::Right, cx), - }, + InternalState::Start => { + let next_side = (this.clos)(this.state); + poll_inner(&mut this, next_side, cx) + } InternalState::LeftFinished => match this.stream2.poll_next(cx) { Poll::Ready(None) => { *this.internal_state = InternalState::BothFinished;