1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use source::from_iter;
use source::FromIter;
pub fn from_factory<F, S>(factory: F) -> FromIter<FromFactoryIter<F>>
where
F: FnMut() -> Option<S>,
{
from_iter(FromFactoryIter { factory: factory })
}
pub struct FromFactoryIter<F> {
factory: F,
}
impl<F, S> Iterator for FromFactoryIter<F>
where
F: FnMut() -> Option<S>,
{
type Item = S;
#[inline]
fn next(&mut self) -> Option<S> {
(self.factory)()
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
(0, None)
}
}