Skip to content

Commit 612be77

Browse files
committed
Merge pull request #20500 from globin/fix/range-sugar
Fix range sugar Reviewed-by: nick29581
2 parents 05164ba + 5cc1738 commit 612be77

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/libcore/iter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,10 +2726,10 @@ pub trait Step: Ord {
27262726
/// Change self to the previous object.
27272727
fn step_back(&mut self);
27282728
/// The steps_between two step objects.
2729-
/// a should always be less than b, so the result should never be negative.
2729+
/// start should always be less than end, so the result should never be negative.
27302730
/// Return None if it is not possible to calculate steps_between without
27312731
/// overflow.
2732-
fn steps_between(a: &Self, b: &Self) -> Option<uint>;
2732+
fn steps_between(start: &Self, end: &Self) -> Option<uint>;
27332733
}
27342734

27352735
macro_rules! step_impl {
@@ -2741,9 +2741,9 @@ macro_rules! step_impl {
27412741
#[inline]
27422742
fn step_back(&mut self) { *self -= 1; }
27432743
#[inline]
2744-
fn steps_between(a: &$t, b: &$t) -> Option<uint> {
2745-
debug_assert!(a < b);
2746-
Some((*a - *b) as uint)
2744+
fn steps_between(start: &$t, end: &$t) -> Option<uint> {
2745+
debug_assert!(end >= start);
2746+
Some((*end - *start) as uint)
27472747
}
27482748
}
27492749
)*)
@@ -2758,7 +2758,7 @@ macro_rules! step_impl_no_between {
27582758
#[inline]
27592759
fn step_back(&mut self) { *self -= 1; }
27602760
#[inline]
2761-
fn steps_between(_a: &$t, _b: &$t) -> Option<uint> {
2761+
fn steps_between(_start: &$t, _end: &$t) -> Option<uint> {
27622762
None
27632763
}
27642764
}

src/libcore/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ impl<Idx: Clone + Step> Iterator for Range<Idx> {
943943

944944
#[inline]
945945
fn size_hint(&self) -> (uint, Option<uint>) {
946-
if let Some(hint) = Step::steps_between(&self.end, &self.start) {
946+
if let Some(hint) = Step::steps_between(&self.start, &self.end) {
947947
(hint, Some(hint))
948948
} else {
949949
(0, None)

0 commit comments

Comments
 (0)