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

Creates an iterator that endlessly returns items from a function call.

let mut count = 0;
let mut streaming_iter = streaming_iterator::repeat_with(|| {
    count += 1;
    count
});
assert_eq!(streaming_iter.next(), Some(&1));
assert_eq!(streaming_iter.next(), Some(&2));
assert_eq!(streaming_iter.next(), Some(&3));
assert_eq!(streaming_iter.next(), Some(&4));
assert_eq!(streaming_iter.next(), Some(&5));
// ...