summaryrefslogtreecommitdiff
path: root/src/poly/iter.rs
blob: 26c598991cd72aa73a611304eccad4eb82ce43a3 (plain)
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
use crate::number::Number;

pub struct Iter {
    index: usize,
    data: Vec<Number>
}

impl Iter {
    pub fn new(data: Vec<Number>) -> Iter {
        Iter { index: 0, data }
    }
}

impl Iterator for Iter {
    type Item = Number;

    fn next(&mut self) -> Option<Number> {
        self.index += 1;
        if self.index <= self.data.len() {
            Some(self.data[self.index - 1])
        } else {
            Some(0.0)
        }
    }
}