diff --git a/futures-util/src/stream/stream/all.rs b/futures-util/src/stream/stream/all.rs index ba2baa5cf..b2aaa6b78 100644 --- a/futures-util/src/stream/stream/all.rs +++ b/futures-util/src/stream/stream/all.rs @@ -69,11 +69,12 @@ where if let Some(fut) = this.future.as_mut().as_pin_mut() { // we're currently processing a future to produce a new accum value let acc = this.accum.unwrap() && ready!(fut.poll(cx)); + this.future.set(None); if !acc { + this.accum.take().unwrap(); break false; } // early exit *this.accum = Some(acc); - this.future.set(None); } else if this.accum.is_some() { // we're waiting on a new item from the stream match ready!(this.stream.as_mut().poll_next(cx)) { diff --git a/futures-util/src/stream/stream/any.rs b/futures-util/src/stream/stream/any.rs index f023125c7..f8b2a5829 100644 --- a/futures-util/src/stream/stream/any.rs +++ b/futures-util/src/stream/stream/any.rs @@ -69,11 +69,12 @@ where if let Some(fut) = this.future.as_mut().as_pin_mut() { // we're currently processing a future to produce a new accum value let acc = this.accum.unwrap() || ready!(fut.poll(cx)); + this.future.set(None); if acc { + this.accum.take().unwrap(); break true; } // early exit *this.accum = Some(acc); - this.future.set(None); } else if this.accum.is_some() { // we're waiting on a new item from the stream match ready!(this.stream.as_mut().poll_next(cx)) {