Function rin::ecs::streaming_iterator::repeat_with [−][src]
pub fn repeat_with<T, F>(gen: F) -> RepeatWith<T, F> where
F: FnMut() -> T,
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)); // ...