Function rin::ecs::streaming_iterator::from_fn[][src]

pub fn from_fn<T, F>(gen: F) -> FromFn<T, F> where
    F: FnMut() -> Option<T>, 

Creates an iterator that returns items from a function call.

let mut count = 0;
let mut streaming_iter = streaming_iterator::from_fn(|| {
    count += 1;
    if count < 4 { Some(count) } else { None }
});
assert_eq!(streaming_iter.next(), Some(&1));
assert_eq!(streaming_iter.next(), Some(&2));
assert_eq!(streaming_iter.next(), Some(&3));
assert_eq!(streaming_iter.next(), None);