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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
pub
struct Map<I, F, NewItemType>
where
I : LendingIterator,
NewItemType : HKT,
for<'any>
F : FnMut(
[&'any I; 0],
Item<'any, I>,
) -> A!(NewItemType<'any>)
,
{
pub(in crate)
iter: I,
pub(in crate)
map: F,
pub(in crate)
_phantom_ty: ::core::marker::PhantomData<fn() -> NewItemType>,
}
#[gat]
impl<I, NewItemType, F> LendingIterator
for Map<I, F, NewItemType>
where
I : LendingIterator,
NewItemType : HKT,
for<'any>
F : FnMut(
[&'any I; 0],
Item<'any, I>,
) -> A!(NewItemType<'any>)
,
{
type Item<'next>
where
Self : 'next,
=
A!(NewItemType<'next>)
;
fn next (
self: &'_ mut Map<I, F, NewItemType>,
) -> Option<A!(NewItemType<'_>)>
{
self.iter.next().map(|item| (self.map)([], item))
}
}
pub
struct MapIntoIter<I, F>
(
pub(in crate) I,
pub(in crate) F,
)
where
I : LendingIterator,
for<'any>
F : crate::utils::FnMut<Item<'any, I>>
,
;
impl<I, F, R>
Iterator
for
MapIntoIter<I, F>
where
I : LendingIterator,
F : FnMut(Item<'_, I>) -> R,
{
type Item = R;
fn next (
self: &'_ mut MapIntoIter<I, F>,
) -> Option<R>
{
self.0.next().map(&mut self.1)
}
}