Function Subspace :: sus :: iter :: once

template <class Item>
auto once(Item o) -> Once<Item>

Constructs a Once iterator that will return o and then None.

Examples

An iterator that returns a number once:

auto o = sus::iter::once<u16>(3_u16);
sus_check(o.next().unwrap() == 3_u16);
sus_check(o.next().is_none());

An iterator that returns a reference once:

auto u = 3_u16;
auto o = sus::iter::once<u16&>(u);
u16& r = o.next().unwrap();
sus_check(r == 3u);
sus_check(&r == &u);
sus_check(o.next().is_none());