Function streaming_iterator::once_with
source · Expand description
Creates an iterator that returns exactly one item from a function call.
#[derive(Debug, PartialEq)]
struct Expensive(i32);
let mut streaming_iter = streaming_iterator::once_with(|| Expensive(1));
assert_eq!(streaming_iter.next(), Some(&Expensive(1)));
assert_eq!(streaming_iter.next(), None);