forked from mirror/async-std
Duplicating code due to strange Rust error.
This commit is contained in:
parent
0c37d4af10
commit
e48e463736
1 changed files with 18 additions and 19 deletions
|
@ -45,26 +45,25 @@ where
|
||||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
let this = self.project();
|
let this = self.project();
|
||||||
if utils::random(1) == 1 {
|
if utils::random(1) == 1 {
|
||||||
poll_next_in_order(cx, this.left, this.right)
|
match this.left.poll_next(cx) {
|
||||||
} else {
|
|
||||||
poll_next_in_order(cx, this.right, this.left)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pools the next item, trying in order, first the first item, then the second one.
|
|
||||||
fn poll_next_in_order<F, S, T>(cx: &mut Context<'_>, first: F, second: S) -> Poll<Option<T>>
|
|
||||||
where
|
|
||||||
F: Stream<Item = T>,
|
|
||||||
S: Stream<Item = T>,
|
|
||||||
{
|
|
||||||
match first.poll_next(cx) {
|
|
||||||
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
||||||
Poll::Ready(None) => second.poll_next(cx),
|
Poll::Ready(None) => this.right.poll_next(cx),
|
||||||
Poll::Pending => match second.poll_next(cx) {
|
Poll::Pending => match this.right.poll_next(cx) {
|
||||||
|
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
||||||
|
Poll::Ready(None) => Poll::Pending,
|
||||||
|
Poll::Pending => Poll::Pending,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match this.right.poll_next(cx) {
|
||||||
|
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
||||||
|
Poll::Ready(None) => this.left.poll_next(cx),
|
||||||
|
Poll::Pending => match this.left.poll_next(cx) {
|
||||||
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
||||||
Poll::Ready(None) => Poll::Pending,
|
Poll::Ready(None) => Poll::Pending,
|
||||||
Poll::Pending => Poll::Pending,
|
Poll::Pending => Poll::Pending,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue