Function futures_util::sink::unfold [−][src]
pub fn unfold<T, F, R>(init: T, function: F) -> Unfold<T, F, R>
Create a sink from a function which processes one item at a time.
Examples
use futures::sink::{self, SinkExt}; let unfold = sink::unfold(0, |mut sum, i: i32| { async move { sum += i; eprintln!("{}", i); Ok::<_, futures::never::Never>(sum) } }); futures::pin_mut!(unfold); unfold.send(5).await?;