diff --git a/src/stream/successor.rs b/src/stream/successor.rs index 434ef97..3ddeef4 100644 --- a/src/stream/successor.rs +++ b/src/stream/successor.rs @@ -39,9 +39,9 @@ where Fut: Future /// }); /// /// pin_utils::pin_mut!(s); -/// assert_eq!(s.next().await, Some(1)); -/// assert_eq!(s.next().await, Some(2)); -/// assert_eq!(s.next().await, Some(3)); +/// assert_eq!(s.next().await, Some(23)); +/// assert_eq!(s.next().await, Some(24)); +/// assert_eq!(s.next().await, Some(25)); /// # /// # }) } /// @@ -83,20 +83,18 @@ where fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &self.future { - Some(_) => { - let next = futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx)); - self.as_mut().future().set(None); - - Poll::Ready(Some(next)) - }, None => { let x = self.next; let fut = (self.as_mut().successor())(x); self.as_mut().future().set(Some(fut)); - // Probably can poll the value here? - Poll::Pending } + _ => {}, } + + let next = futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx)); + *self.as_mut().next() = next; + self.as_mut().future().set(None); + Poll::Ready(Some(next)) } }