Function streaming_iterator::once_with [−][src]
pub fn once_with<T, F: FnOnce() -> T>(gen: F) -> OnceWith<T, F>
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);