pub fn repeat_with<T, F>(repeater: F) -> RepeatWith<F>
where F: FnMut() -> T,
Expand description

Creates an infinite stream from a closure that generates items.

Examples

use futures_lite::stream::{self, StreamExt};

let mut s = stream::repeat_with(|| 7);

assert_eq!(s.next().await, Some(7));
assert_eq!(s.next().await, Some(7));