@@ -1719,6 +1719,20 @@ pub fn count<A>(start: A, step: A) -> Counter<A> {
1719
1719
Counter { state : start, step : step}
1720
1720
}
1721
1721
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
+
1722
1736
/// An iterator over the range [start, stop)
1723
1737
#[ deriving( Clone , DeepClone ) ]
1724
1738
pub struct Range < A > {
@@ -1824,20 +1838,6 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu
1824
1838
}
1825
1839
}
1826
1840
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
-
1841
1841
/// An iterator that repeats an element endlessly
1842
1842
#[ deriving( Clone , DeepClone ) ]
1843
1843
pub struct Repeat < A > {
0 commit comments