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 crate::{Key, Spline};
pub struct Iter<'a, T, V> where T: 'a, V: 'a {
spline: &'a Spline<T, V>,
i: usize
}
impl<'a, T, V> Iterator for Iter<'a, T, V> {
type Item = &'a Key<T, V>;
fn next(&mut self) -> Option<Self::Item> {
let r = self.spline.0.get(self.i);
if let Some(_) = r {
self.i += 1;
}
r
}
}
impl<'a, T, V> IntoIterator for &'a Spline<T, V> {
type Item = &'a Key<T, V>;
type IntoIter = Iter<'a, T, V>;
fn into_iter(self) -> Self::IntoIter {
Iter {
spline: self,
i: 0
}
}
}