pub struct RectIter { points: Vec<(f64, f64)>, idx: usize, } impl Iterator for RectIter { type Item = (f64, f64); /* * The reason why is mutable (&mut self), is that the only way to iterate through something, * is that the underline iterator has to be mutable, bacause you have to be able to change * the state until you are at the end. */ fn next(&mut self) -> Option { if self.idx >= self.points.len() { return None; } let point = self.points[self.idx]; self.idx += 1; return Some(point); } }