iter: move Counter impl to the proper place
This commit is contained in:
parent
10c8978edb
commit
3aead52586
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user