Skip to content

Commit

Permalink
Stream selection passes PollNext by value internally
Browse files Browse the repository at this point in the history
  • Loading branch information
414owen committed Mar 25, 2022
1 parent d382150 commit dc0ec68
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions futures-util/src/stream/select_with_strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -209,7 +209,7 @@ where
#[inline(always)]
fn poll_side<St1, St2, Clos, State>(
select: &mut SelectWithStrategyProj<'_, St1, St2, Clos, State>,
side: &PollNext,
side: PollNext,
cx: &mut Context<'_>,
) -> Poll<Option<St1::Item>>
where
Expand All @@ -225,7 +225,7 @@ where
#[inline(always)]
fn poll_inner<St1, St2, Clos, State>(
select: &mut SelectWithStrategyProj<'_, St1, St2, Clos, State>,
side: &PollNext,
side: PollNext,
cx: &mut Context<'_>,
) -> Poll<Option<St1::Item>>
where
Expand All @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit dc0ec68

Please sign in to comment.