diff --git a/src/stream/successors.rs b/src/stream/successors.rs index f7d5bd8..446ffe5 100644 --- a/src/stream/successors.rs +++ b/src/stream/successors.rs @@ -18,7 +18,7 @@ use pin_project_lite::pin_project; /// use async_std::prelude::*; /// use async_std::stream; /// -/// let s = stream::successors(Some(22), |val| { +/// let s = stream::successors(Some(22), |&val| { /// async move { /// Some(val + 1) /// } @@ -31,9 +31,9 @@ use pin_project_lite::pin_project; /// assert_eq!(s.next().await, Some(25)); /// /// -///let never = stream::successors(None, |val: usize| { +///let never = stream::successors(None, |_| { /// async move { -/// Some(val + 1) +/// Some(1) /// } /// }); /// @@ -48,7 +48,7 @@ use pin_project_lite::pin_project; #[cfg_attr(feature = "docs", doc(cfg(unstable)))] pub fn successors(first: Option, succ: F) -> Successors where - F: FnMut(T) -> Fut, + F: FnMut(&T) -> Fut, Fut: Future>, T: Copy, { @@ -83,7 +83,7 @@ pin_project! { impl Stream for Successors where Fut: Future>, - F: FnMut(T) -> Fut, + F: FnMut(&T) -> Fut, T: Copy, { type Item = T; @@ -96,7 +96,7 @@ where } if this.future.is_none() { - let fut = (this.succ)(this.slot.unwrap()); + let fut = (this.succ)(&this.slot.unwrap()); this.future.set(Some(fut)); }