Skip to content

Commit 3aead52

Browse files
committed
iter: move Counter impl to the proper place
1 parent 10c8978 commit 3aead52

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/libstd/iter.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,20 @@ pub fn count<A>(start: A, step: A) -> Counter<A> {
17191719
Counter{state: start, step: step}
17201720
}
17211721

1722+
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
1723+
#[inline]
1724+
fn next(&mut self) -> Option<A> {
1725+
let result = self.state.clone();
1726+
self.state = self.state + self.step;
1727+
Some(result)
1728+
}
1729+
1730+
#[inline]
1731+
fn size_hint(&self) -> (uint, Option<uint>) {
1732+
(uint::max_value, None) // Too bad we can't specify an infinite lower bound
1733+
}
1734+
}
1735+
17221736
/// An iterator over the range [start, stop)
17231737
#[deriving(Clone, DeepClone)]
17241738
pub struct Range<A> {
@@ -1824,20 +1838,6 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu
18241838
}
18251839
}
18261840

1827-
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
1828-
#[inline]
1829-
fn next(&mut self) -> Option<A> {
1830-
let result = self.state.clone();
1831-
self.state = self.state + self.step;
1832-
Some(result)
1833-
}
1834-
1835-
#[inline]
1836-
fn size_hint(&self) -> (uint, Option<uint>) {
1837-
(uint::max_value, None) // Too bad we can't specify an infinite lower bound
1838-
}
1839-
}
1840-
18411841
/// An iterator that repeats an element endlessly
18421842
#[deriving(Clone, DeepClone)]
18431843
pub struct Repeat<A> {

0 commit comments

Comments
 (0)