summaryrefslogtreecommitdiff
path: root/src/poly/iter.rs
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-11 08:42:04 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2021-01-11 08:42:04 -0300
commit6262cd9aab04bce1c98fd5f6ab19cd5da814dfc7 (patch)
tree6ddb856d1e11ebea1bc12771b98623dc30070b2a /src/poly/iter.rs
parent7fa34698ba8ee80227fa0b8eaab7a7382a5cf465 (diff)
downloadbezier-6262cd9aab04bce1c98fd5f6ab19cd5da814dfc7.tar.gz
bezier-6262cd9aab04bce1c98fd5f6ab19cd5da814dfc7.zip
Implement add and sub for P
Diffstat (limited to 'src/poly/iter.rs')
-rw-r--r--src/poly/iter.rs25
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)
+ }
+ }
+}