Skip to main content

fallible_once

Function fallible_once 

Source
pub fn fallible_once<'a, L: ?Sized + CovariantFallibleLending, E>(
    value: FallibleLend<'a, L>,
) -> Once<'a, L, E>
Expand description

Creates a fallible lender that yields a value exactly once.

This is the FallibleLender equivalent of core::iter::once(): it yields one item and then returns Ok(None).

To create a lender that yields a single error, use once_err().

ยงExamples

let mut lender = lender::fallible_once::<
    fallible_lend!(&'lend i32), String,
>(&42);
assert_eq!(lender.next(), Ok(Some(&42)));
assert_eq!(lender.next(), Ok(None));