Skip to main content

fallible_repeat_with_err

Function fallible_repeat_with_err 

Source
pub fn fallible_repeat_with_err<L, F>(f: F) -> RepeatWithErr<L, F>
where L: ?Sized + CovariantFallibleLending,
Expand description

Creates a new fallible lender that endlessly repeats errors generated by a closure.

This is the error counterpart to repeat_with(): it calls the closure on every call to next and yields the result as an error.

ยงExamples

let mut count = 0;
let mut lender = lender::fallible_repeat_with_err::<
    fallible_lend!(&'lend i32), _,
>(move || { count += 1; format!("error #{count}") });
assert_eq!(lender.next(), Err("error #1".to_string()));
assert_eq!(lender.next(), Err("error #2".to_string()));