Function Subspace :: sus :: iter :: once_with
Creates an iterator that lazily generates a value exactly once by invoking the provided closure.
This is commonly used to adapt a single value generator into a chain()
of
other kinds of iteration. Maybe you have an iterator that covers almost
everything, but you need an extra special case. Maybe you have a function
which works on iterators, but you only need to process one value.
Unlike once()
, this function will lazily generate the value on request.
Example
auto ow = sus::iter::once_with<u16>([]() { return 3_u16; });
sus_check(ow.next().unwrap() == 3_u16);