Replace buggy range.step_by with a Frame::range_inclusive function

This commit is contained in:
Philipp Oppermann
2016-03-06 12:39:15 +01:00
parent 23df363136
commit 03ed3ce9a0
3 changed files with 35 additions and 15 deletions

View File

@@ -33,6 +33,32 @@ impl Frame {
fn clone(&self) -> Frame {
Frame { number: self.number }
}
fn range_inclusive(start: Frame, end: Frame) -> FrameIter {
FrameIter {
start: start,
end: end,
}
}
}
struct FrameIter {
start: Frame,
end: Frame,
}
impl Iterator for FrameIter {
type Item = Frame;
fn next(&mut self) -> Option<Frame> {
if self.start <= self.end {
let frame = self.start.clone();
self.start.number += 1;
Some(frame)
} else {
None
}
}
}
pub trait FrameAllocator {