mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-25 01:36:50 +00:00
Fixes review issues
This commit is contained in:
parent
0080a0da8c
commit
efe351659f
1 changed files with 10 additions and 10 deletions
|
@ -31,23 +31,23 @@ impl<S, F, T, B> FoldFuture<S, F, T, B> {
|
||||||
|
|
||||||
impl<S, F, B> Future for FoldFuture<S, F, S::Item, B>
|
impl<S, F, B> Future for FoldFuture<S, F, S::Item, B>
|
||||||
where
|
where
|
||||||
S: Stream + Unpin + Sized,
|
S: Stream + Sized,
|
||||||
F: FnMut(B, S::Item) -> B,
|
F: FnMut(B, S::Item) -> B,
|
||||||
{
|
{
|
||||||
type Output = B;
|
type Output = B;
|
||||||
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
|
loop {
|
||||||
let next = futures_core::ready!(self.as_mut().stream().poll_next(cx));
|
let next = futures_core::ready!(self.as_mut().stream().poll_next(cx));
|
||||||
|
|
||||||
match next {
|
match next {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
cx.waker().wake_by_ref();
|
|
||||||
let old = self.as_mut().acc().take().unwrap();
|
let old = self.as_mut().acc().take().unwrap();
|
||||||
let new = (self.as_mut().f())(old, v);
|
let new = (self.as_mut().f())(old, v);
|
||||||
*self.as_mut().acc() = Some(new);
|
*self.as_mut().acc() = Some(new);
|
||||||
Poll::Pending
|
|
||||||
}
|
}
|
||||||
None => Poll::Ready(self.as_mut().acc().take().unwrap()),
|
None => return Poll::Ready(self.as_mut().acc().take().unwrap()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue