From a257b7018c83748ff98f07a9592aa7b29f6f62ef Mon Sep 17 00:00:00 2001 From: Felipe Sere Date: Sun, 10 Nov 2019 14:29:43 +0100 Subject: [PATCH] Rename some variables to match iter --- src/stream/successors.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/stream/successors.rs b/src/stream/successors.rs index 4186c66..7f598f5 100644 --- a/src/stream/successors.rs +++ b/src/stream/successors.rs @@ -1,4 +1,3 @@ -use std::marker::PhantomData; use std::pin::Pin; use std::mem; @@ -12,19 +11,18 @@ pin_project_lite::pin_project! { /// A stream that yields elements by calling an async closure with the previous value as an /// argument /// - /// This stream is constructed by [`successor`] function + /// This stream is constructed by [`successors`] function /// - /// [`successor`]: fn.successor.html + /// [`succcessors`]: fn.succssors.html #[derive(Debug)] pub struct Successors where Fut: Future>, { - successor: F, + succ: F, #[pin] future: Option, slot: Option, - _marker: PhantomData, } } @@ -72,10 +70,9 @@ where T: Copy, { Successors { - successor: succ, + succ: succ, future: None, slot: first, - _marker: PhantomData, } } @@ -95,14 +92,15 @@ where } if this.future.is_none() { - let x = this.slot.unwrap(); - let fut = (this.successor)(x); + let fut = (this.succ)(this.slot.unwrap()); this.future.set(Some(fut)); } let mut next = ready!(this.future.as_mut().as_pin_mut().unwrap().poll(cx)); this.future.set(None); + + // 'swapping' here means 'slot' will hold the next value and next will be th one from the previous iteration mem::swap(this.slot, &mut next); Poll::Ready(next) }