@@ -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;
@@ -2431,7 +2431,7 @@ impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
2431
2431
/// two `Step` objects.
2432
2432
#[ unstable( feature = "step_trait" ,
2433
2433
reason = "likely to be replaced by finer-grained traits" ) ]
2434
- pub trait Step : Ord {
2434
+ pub trait Step : PartialOrd {
2435
2435
/// Steps `self` if possible.
2436
2436
fn step ( & self , by : & Self ) -> Option < Self > ;
2437
2437
@@ -2598,7 +2598,10 @@ pub fn range_inclusive<A>(start: A, stop: A) -> RangeInclusive<A>
2598
2598
2599
2599
#[ unstable( feature = "core" ,
2600
2600
reason = "likely to be replaced by range notation and adapters" ) ]
2601
- impl < A : Step + One + Clone > Iterator for RangeInclusive < A > {
2601
+ impl < A > Iterator for RangeInclusive < A > where
2602
+ A : PartialEq + Step + One + Clone ,
2603
+ for < ' a > & ' a A : Add < & ' a A , Output = A >
2604
+ {
2602
2605
type Item = A ;
2603
2606
2604
2607
#[ inline]
@@ -2628,9 +2631,10 @@ impl<A: Step + One + Clone> Iterator for RangeInclusive<A> {
2628
2631
2629
2632
#[ unstable( feature = "core" ,
2630
2633
reason = "likely to be replaced by range notation and adapters" ) ]
2631
- impl < A > DoubleEndedIterator for RangeInclusive < A >
2632
- where A : Step + One + Clone ,
2633
- for < ' a > & ' a A : Sub < Output =A >
2634
+ impl < A > DoubleEndedIterator for RangeInclusive < A > where
2635
+ A : PartialEq + Step + One + Clone ,
2636
+ for < ' a > & ' a A : Add < & ' a A , Output = A > ,
2637
+ for < ' a > & ' a A : Sub < Output =A >
2634
2638
{
2635
2639
#[ inline]
2636
2640
fn next_back ( & mut self ) -> Option < A > {
@@ -2758,24 +2762,17 @@ macro_rules! range_exact_iter_impl {
2758
2762
2759
2763
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2760
2764
#[ allow( deprecated) ]
2761
- impl < A : Step + One + Clone > Iterator for ops:: Range < A > {
2765
+ impl < A : Step + One > Iterator for ops:: Range < A > where
2766
+ for < ' a > & ' a A : Add < & ' a A , Output = A >
2767
+ {
2762
2768
type Item = A ;
2763
2769
2764
2770
#[ inline]
2765
2771
fn next ( & mut self ) -> Option < A > {
2766
2772
if self . start < self . end {
2767
- match self . start . step ( & A :: one ( ) ) {
2768
- Some ( mut n) => {
2769
- mem:: swap ( & mut n, & mut self . start ) ;
2770
- Some ( n)
2771
- } ,
2772
- None => {
2773
- let mut n = self . end . clone ( ) ;
2774
- mem:: swap ( & mut n, & mut self . start ) ;
2775
- Some ( n)
2776
-
2777
- }
2778
- }
2773
+ let mut n = & self . start + & A :: one ( ) ;
2774
+ mem:: swap ( & mut n, & mut self . start ) ;
2775
+ Some ( n)
2779
2776
} else {
2780
2777
None
2781
2778
}
@@ -2797,6 +2794,7 @@ range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
2797
2794
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2798
2795
#[ allow( deprecated) ]
2799
2796
impl < A : Step + One + Clone > DoubleEndedIterator for ops:: Range < A > where
2797
+ for < ' a > & ' a A : Add < & ' a A , Output = A > ,
2800
2798
for < ' a > & ' a A : Sub < & ' a A , Output = A >
2801
2799
{
2802
2800
#[ inline]
@@ -2812,15 +2810,16 @@ impl<A: Step + One + Clone> DoubleEndedIterator for ops::Range<A> where
2812
2810
2813
2811
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2814
2812
#[ allow( deprecated) ]
2815
- impl < A : Step + One > Iterator for ops:: RangeFrom < A > {
2813
+ impl < A : Step + One > Iterator for ops:: RangeFrom < A > where
2814
+ for < ' a > & ' a A : Add < & ' a A , Output = A >
2815
+ {
2816
2816
type Item = A ;
2817
2817
2818
2818
#[ inline]
2819
2819
fn next ( & mut self ) -> Option < A > {
2820
- self . start . step ( & A :: one ( ) ) . map ( |mut n| {
2821
- mem:: swap ( & mut n, & mut self . start ) ;
2822
- n
2823
- } )
2820
+ let mut n = & self . start + & A :: one ( ) ;
2821
+ mem:: swap ( & mut n, & mut self . start ) ;
2822
+ Some ( n)
2824
2823
}
2825
2824
}
2826
2825
0 commit comments