futures_lite::stream

Function repeat_with

source
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));