diff options
Diffstat (limited to 'src/poly')
-rw-r--r-- | src/poly/iter.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/poly/iter.rs b/src/poly/iter.rs new file mode 100644 index 0000000..26c5989 --- /dev/null +++ b/src/poly/iter.rs @@ -0,0 +1,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) + } + } +} |