@@ -60,7 +60,7 @@ use self::MinMaxResult::*;
60
60
61
61
use clone:: Clone ;
62
62
use cmp;
63
- use cmp:: Ord ;
63
+ use cmp:: { Ord , PartialOrd , PartialEq } ;
64
64
use default:: Default ;
65
65
use marker;
66
66
use mem;
@@ -2382,7 +2382,7 @@ impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
2382
2382
/// two `Step` objects.
2383
2383
#[ unstable( feature = "step_trait" ,
2384
2384
reason = "likely to be replaced by finer-grained traits" ) ]
2385
- pub trait Step : Ord {
2385
+ pub trait Step : PartialOrd {
2386
2386
/// Steps `self` if possible.
2387
2387
fn step ( & self , by : & Self ) -> Option < Self > ;
2388
2388
@@ -2549,7 +2549,10 @@ pub fn range_inclusive<A>(start: A, stop: A) -> RangeInclusive<A>
2549
2549
2550
2550
#[ unstable( feature = "core" ,
2551
2551
reason = "likely to be replaced by range notation and adapters" ) ]
2552
- impl < A : Step + One + Clone > Iterator for RangeInclusive < A > {
2552
+ impl < A > Iterator for RangeInclusive < A > where
2553
+ A : PartialEq + Step + One + Clone ,
2554
+ for < ' a > & ' a A : Add < & ' a A , Output = A >
2555
+ {
2553
2556
type Item = A ;
2554
2557
2555
2558
#[ inline]
@@ -2579,9 +2582,10 @@ impl<A: Step + One + Clone> Iterator for RangeInclusive<A> {
2579
2582
2580
2583
#[ unstable( feature = "core" ,
2581
2584
reason = "likely to be replaced by range notation and adapters" ) ]
2582
- impl < A > DoubleEndedIterator for RangeInclusive < A >
2583
- where A : Step + One + Clone ,
2584
- for < ' a > & ' a A : Sub < Output =A >
2585
+ impl < A > DoubleEndedIterator for RangeInclusive < A > where
2586
+ A : PartialEq + Step + One + Clone ,
2587
+ for < ' a > & ' a A : Add < & ' a A , Output = A > ,
2588
+ for < ' a > & ' a A : Sub < Output =A >
2585
2589
{
2586
2590
#[ inline]
2587
2591
fn next_back ( & mut self ) -> Option < A > {
@@ -2709,24 +2713,17 @@ macro_rules! range_exact_iter_impl {
2709
2713
2710
2714
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2711
2715
#[ allow( deprecated) ]
2712
- impl < A : Step + One + Clone > Iterator for ops:: Range < A > {
2716
+ impl < A : Step + One > Iterator for ops:: Range < A > where
2717
+ for < ' a > & ' a A : Add < & ' a A , Output = A >
2718
+ {
2713
2719
type Item = A ;
2714
2720
2715
2721
#[ inline]
2716
2722
fn next ( & mut self ) -> Option < A > {
2717
2723
if self . start < self . end {
2718
- match self . start . step ( & A :: one ( ) ) {
2719
- Some ( mut n) => {
2720
- mem:: swap ( & mut n, & mut self . start ) ;
2721
- Some ( n)
2722
- } ,
2723
- None => {
2724
- let mut n = self . end . clone ( ) ;
2725
- mem:: swap ( & mut n, & mut self . start ) ;
2726
- Some ( n)
2727
-
2728
- }
2729
- }
2724
+ let mut n = & self . start + & A :: one ( ) ;
2725
+ mem:: swap ( & mut n, & mut self . start ) ;
2726
+ Some ( n)
2730
2727
} else {
2731
2728
None
2732
2729
}
@@ -2748,6 +2745,7 @@ range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
2748
2745
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2749
2746
#[ allow( deprecated) ]
2750
2747
impl < A : Step + One + Clone > DoubleEndedIterator for ops:: Range < A > where
2748
+ for < ' a > & ' a A : Add < & ' a A , Output = A > ,
2751
2749
for < ' a > & ' a A : Sub < & ' a A , Output = A >
2752
2750
{
2753
2751
#[ inline]
@@ -2763,15 +2761,16 @@ impl<A: Step + One + Clone> DoubleEndedIterator for ops::Range<A> where
2763
2761
2764
2762
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2765
2763
#[ allow( deprecated) ]
2766
- impl < A : Step + One > Iterator for ops:: RangeFrom < A > {
2764
+ impl < A : Step + One > Iterator for ops:: RangeFrom < A > where
2765
+ for < ' a > & ' a A : Add < & ' a A , Output = A >
2766
+ {
2767
2767
type Item = A ;
2768
2768
2769
2769
#[ inline]
2770
2770
fn next ( & mut self ) -> Option < A > {
2771
- self . start . step ( & A :: one ( ) ) . map ( |mut n| {
2772
- mem:: swap ( & mut n, & mut self . start ) ;
2773
- n
2774
- } )
2771
+ let mut n = & self . start + & A :: one ( ) ;
2772
+ mem:: swap ( & mut n, & mut self . start ) ;
2773
+ Some ( n)
2775
2774
}
2776
2775
}
2777
2776
0 commit comments