Skip to content

Commit 5cc1738

Browse files
committed
fix range sugar
1 parent 496dc4e commit 5cc1738

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
@@ -2620,10 +2620,10 @@ pub trait Step: Ord {
26202620
/// Change self to the previous object.
26212621
fn step_back(&mut self);
26222622
/// The steps_between two step objects.
2623-
/// a should always be less than b, so the result should never be negative.
2623+
/// start should always be less than end, so the result should never be negative.
26242624
/// Return None if it is not possible to calculate steps_between without
26252625
/// overflow.
2626-
fn steps_between(a: &Self, b: &Self) -> Option<uint>;
2626+
fn steps_between(start: &Self, end: &Self) -> Option<uint>;
26272627
}
26282628

26292629
macro_rules! step_impl {
@@ -2635,9 +2635,9 @@ macro_rules! step_impl {
26352635
#[inline]
26362636
fn step_back(&mut self) { *self -= 1; }
26372637
#[inline]
2638-
fn steps_between(a: &$t, b: &$t) -> Option<uint> {
2639-
debug_assert!(a < b);
2640-
Some((*a - *b) as uint)
2638+
fn steps_between(start: &$t, end: &$t) -> Option<uint> {
2639+
debug_assert!(end >= start);
2640+
Some((*end - *start) as uint)
26412641
}
26422642
}
26432643
)*)
@@ -2652,7 +2652,7 @@ macro_rules! step_impl_no_between {
26522652
#[inline]
26532653
fn step_back(&mut self) { *self -= 1; }
26542654
#[inline]
2655-
fn steps_between(_a: &$t, _b: &$t) -> Option<uint> {
2655+
fn steps_between(_start: &$t, _end: &$t) -> Option<uint> {
26562656
None
26572657
}
26582658
}

src/libcore/ops.rs

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

804804
#[inline]
805805
fn size_hint(&self) -> (uint, Option<uint>) {
806-
if let Some(hint) = Step::steps_between(&self.end, &self.start) {
806+
if let Some(hint) = Step::steps_between(&self.start, &self.end) {
807807
(hint, Some(hint))
808808
} else {
809809
(0, None)

0 commit comments

Comments
 (0)