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
use ArgdataRef;
use ReadError;
pub trait Seq<'d> {
fn iter_seq_next<'a>(
&'a self,
cookie: &mut usize,
) -> Option<Result<ArgdataRef<'a, 'd>, ReadError>>
where
'd: 'a;
}
impl<'a, 'd: 'a> Seq<'d> + 'a {
pub fn iter_seq(&'a self) -> SeqIterator<'a, 'd> {
SeqIterator {
seq: self,
cookie: 0,
}
}
}
pub struct SeqIterator<'a, 'd: 'a> {
seq: &'a (Seq<'d> + 'a),
cookie: usize,
}
impl<'a, 'd: 'a> Iterator for SeqIterator<'a, 'd> {
type Item = Result<ArgdataRef<'a, 'd>, ReadError>;
fn next(&mut self) -> Option<Self::Item> {
self.seq.iter_seq_next(&mut self.cookie)
}
}