Function itertools::repeat_call [−][src]
pub fn repeat_call<F, A>(function: F) -> RepeatCall<F>ⓘwhereNotable traits for RepeatCall<F>
impl<A, F> Iterator for RepeatCall<F> where
F: FnMut() -> A, type Item = A;
F: FnMut() -> A,
👎 Deprecated since 0.8:
Use std repeat_with() instead
An iterator source that produces elements indefinitely by calling a given closure.
Iterator element type is the return type of the closure.
use itertools::repeat_call; use itertools::Itertools; use std::collections::BinaryHeap; let mut heap = BinaryHeap::from(vec![2, 5, 3, 7, 8]); // extract each element in sorted order for element in repeat_call(|| heap.pop()).while_some() { print!("{}", element); } itertools::assert_equal( repeat_call(|| 1).take(5), vec![1, 1, 1, 1, 1] );