From 6262cd9aab04bce1c98fd5f6ab19cd5da814dfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Mon, 11 Jan 2021 08:42:04 -0300 Subject: Implement add and sub for P --- src/poly/iter.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/poly/iter.rs (limited to 'src/poly') 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 +} + +impl Iter { + pub fn new(data: Vec) -> Iter { + Iter { index: 0, data } + } +} + +impl Iterator for Iter { + type Item = Number; + + fn next(&mut self) -> Option { + self.index += 1; + if self.index <= self.data.len() { + Some(self.data[self.index - 1]) + } else { + Some(0.0) + } + } +} -- cgit v1.2.3