diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-09-14 16:37:52 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-09-14 16:51:55 -0400 |
| commit | 3aead52586d26f375e6318fb6980280db18b70b7 (patch) | |
| tree | 5cd5e24a59b185057f7ee7b2231bac4626834d11 /src | |
| parent | 10c8978edbb53fda8b33758a0bf3f9154b20dc9e (diff) | |
| download | rust-3aead52586d26f375e6318fb6980280db18b70b7.tar.gz rust-3aead52586d26f375e6318fb6980280db18b70b7.zip | |
iter: move Counter impl to the proper place
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/iter.rs | 28 |
1 files changed, 14 insertions, 14 deletions
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<A>(start: A, step: A) -> Counter<A> { Counter{state: start, step: step} } +impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> { + #[inline] + fn next(&mut self) -> Option<A> { + let result = self.state.clone(); + self.state = self.state + self.step; + Some(result) + } + + #[inline] + fn size_hint(&self) -> (uint, Option<uint>) { + (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<A> { @@ -1824,20 +1838,6 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu } } -impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> { - #[inline] - fn next(&mut self) -> Option<A> { - let result = self.state.clone(); - self.state = self.state + self.step; - Some(result) - } - - #[inline] - fn size_hint(&self) -> (uint, Option<uint>) { - (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<A> { |
