diff options
| author | bors <bors@rust-lang.org> | 2015-01-04 21:36:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-04 21:36:39 +0000 |
| commit | 612be77c1f86a2b45471a2630df722e2a8d1d686 (patch) | |
| tree | bef279b47282565c1a935575ce97ba13543f3ec8 /src/libcore | |
| parent | 05164ba1e0ae62cffc4799db35bfb588969662f0 (diff) | |
| parent | 5cc17382d17ff2f9eb335c2e80e28089bb2d5810 (diff) | |
| download | rust-612be77c1f86a2b45471a2630df722e2a8d1d686.tar.gz rust-612be77c1f86a2b45471a2630df722e2a8d1d686.zip | |
Merge pull request #20500 from globin/fix/range-sugar
Fix range sugar Reviewed-by: nick29581
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter.rs | 12 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 62bfa381c44..29077deb21d 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2726,10 +2726,10 @@ pub trait Step: Ord { /// Change self to the previous object. fn step_back(&mut self); /// The steps_between two step objects. - /// a should always be less than b, so the result should never be negative. + /// start should always be less than end, so the result should never be negative. /// Return None if it is not possible to calculate steps_between without /// overflow. - fn steps_between(a: &Self, b: &Self) -> Option<uint>; + fn steps_between(start: &Self, end: &Self) -> Option<uint>; } macro_rules! step_impl { @@ -2741,9 +2741,9 @@ macro_rules! step_impl { #[inline] fn step_back(&mut self) { *self -= 1; } #[inline] - fn steps_between(a: &$t, b: &$t) -> Option<uint> { - debug_assert!(a < b); - Some((*a - *b) as uint) + fn steps_between(start: &$t, end: &$t) -> Option<uint> { + debug_assert!(end >= start); + Some((*end - *start) as uint) } } )*) @@ -2758,7 +2758,7 @@ macro_rules! step_impl_no_between { #[inline] fn step_back(&mut self) { *self -= 1; } #[inline] - fn steps_between(_a: &$t, _b: &$t) -> Option<uint> { + fn steps_between(_start: &$t, _end: &$t) -> Option<uint> { None } } diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 2a7df5db5c9..c9b71092f90 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -943,7 +943,7 @@ impl<Idx: Clone + Step> Iterator for Range<Idx> { #[inline] fn size_hint(&self) -> (uint, Option<uint>) { - if let Some(hint) = Step::steps_between(&self.end, &self.start) { + if let Some(hint) = Step::steps_between(&self.start, &self.end) { (hint, Some(hint)) } else { (0, None) |
