Created
February 1, 2022 03:16
-
-
Save tamird/58998117908e78028f47b667a7bee30b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/third_party/rust_crates/vendor/futures-util/src/stream/select.rs b/third_party/rust_crates/vendor/futures-util/src/stream/select.rs | |
index 133ac6c7ac0..58d71fe1df3 100644 | |
--- a/third_party/rust_crates/vendor/futures-util/src/stream/select.rs | |
+++ b/third_party/rust_crates/vendor/futures-util/src/stream/select.rs | |
@@ -94,16 +94,16 @@ where | |
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<St1::Item>> { | |
let this = self.project(); | |
- if !*this.flag { | |
- poll_inner(this.flag, this.stream1, this.stream2, cx) | |
+ // give the other stream a chance to go first next time | |
+ if !std::mem::replace(this.flag, !*this.flag) { | |
+ poll_inner(this.stream1, this.stream2, cx) | |
} else { | |
- poll_inner(this.flag, this.stream2, this.stream1, cx) | |
+ poll_inner(this.stream2, this.stream1, cx) | |
} | |
} | |
} | |
fn poll_inner<St1, St2>( | |
- flag: &mut bool, | |
a: Pin<&mut St1>, | |
b: Pin<&mut St2>, | |
cx: &mut Context<'_>, | |
@@ -114,8 +114,6 @@ where | |
{ | |
let a_done = match a.poll_next(cx) { | |
Poll::Ready(Some(item)) => { | |
- // give the other stream a chance to go first next time | |
- *flag = !*flag; | |
return Poll::Ready(Some(item)); | |
} | |
Poll::Ready(None) => true, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment