Function async_std::stream::successors [−][src]
pub fn successors<F, T>(first: Option<T>, succ: F) -> Successors<F, T> where
F: FnMut(&T) -> Option<T>,
Creates a new stream where to produce each new element a closure is called with the previous value.
Examples
use async_std::prelude::*; use async_std::stream; let mut s = stream::successors(Some(22), |&val| Some(val + 1)); assert_eq!(s.next().await, Some(22)); assert_eq!(s.next().await, Some(23)); assert_eq!(s.next().await, Some(24)); assert_eq!(s.next().await, Some(25));