diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 8407b068344..faa2d715df4 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -1719,6 +1719,20 @@ pub fn count(start: A, step: A) -> Counter { Counter{state: start, step: step} } +impl + Clone> Iterator for Counter { + #[inline] + fn next(&mut self) -> Option { + let result = self.state.clone(); + self.state = self.state + self.step; + Some(result) + } + + #[inline] + fn size_hint(&self) -> (uint, Option) { + (uint::max_value, None) // Too bad we can't specify an infinite lower bound + } +} + /// An iterator over the range [start, stop) #[deriving(Clone, DeepClone)] pub struct Range { @@ -1824,20 +1838,6 @@ impl + Integer + Ord + Clone> DoubleEndedIterator for RangeInclu } } -impl + Clone> Iterator for Counter { - #[inline] - fn next(&mut self) -> Option { - let result = self.state.clone(); - self.state = self.state + self.step; - Some(result) - } - - #[inline] - fn size_hint(&self) -> (uint, Option) { - (uint::max_value, None) // Too bad we can't specify an infinite lower bound - } -} - /// An iterator that repeats an element endlessly #[deriving(Clone, DeepClone)] pub struct Repeat {