Skip to main content

repeat_with

Function repeat_with 

Source
pub fn repeat_with<'a, L, F>(f: F) -> RepeatWith<'a, L, F>
where L: ?Sized + CovariantLending + 'a, F: FnMut() -> Lend<'a, L>,
Expand description

Creates a new lender that repeats elements endlessly by applying the provided closure, the repeater, F: FnMut() -> A.

The repeat_with() function calls the repeater over and over again.

The Lender version of iter::repeat_with().

ยงExamples

let mut lender = lender::repeat_with::<
    lend!(&'lend i32), _,
>(|| &0);
assert_eq!(lender.next(), Some(&0));