Skip to content

Conversation

pnkfelix
Copy link
Contributor

@pnkfelix pnkfelix commented Jul 1, 2013

r? anyone.

Changes int/uint range_rev to iterate over range (hi,lo] instead of [hi,lo).

Fix #5270.

Also:

  • Adds unit tests for int/uint range functions
  • Updates the uses of range_rev to account for the new semantics. (Note that pretty much all of the updates there were strict improvements to the code in question; yay!)
  • Exposes new function, range_step_inclusive, which does the range [hi,lo], (at least when hi-lo is a multiple of the step parameter).
  • Special-cases when |step| == 1 removing unnecessary bounds-check. (I did not check whether LLVM was already performing this optimization; I figure it would be a net win to not leave that analysis to the compiler. If reviewer objects, I can easily remove that from the refactored code.)

pnkfelix added 2 commits July 1, 2013 12:32
… semantics.

Also added unit tests of range code to test refactoring.  The
num-range-rev.rs test will need to be updated when the range_rev
semantics change.
@pnkfelix
Copy link
Contributor Author

pnkfelix commented Jul 9, 2013

Oh, duh. I thought these commits had included fixes to the test code embedded in e.g. int_macros.rs, but it looks like they do not. No wonder all my bors attempts were failing! Sorry for the many misfires, everyone. Will fix soon.

@pnkfelix
Copy link
Contributor Author

closing in favor of rebased version in #7684.

@pnkfelix pnkfelix closed this Jul 10, 2013
bors added a commit that referenced this pull request Jul 16, 2013
…ss-issue5270-2ndpr, r=cmr

Changes int/uint range_rev to iterate over range `(hi,lo]` instead of `[hi,lo)`.

Fix #5270.

Also:
* Adds unit tests for int/uint range functions
* Updates the uses of `range_rev` to account for the new semantics.  (Note that pretty much all of the updates there were strict improvements to the code in question; yay!)
* Exposes new function, `range_step_inclusive`, which does the range `[hi,lo]`, (at least when `hi-lo` is a multiple of the `step` parameter).
* Special-cases when `|step| == 1` removing unnecessary bounds-check.  (I did not check whether LLVM was already performing this optimization; I figure it would be a net win to not leave that analysis to the compiler.  If reviewer objects, I can easily remove that from the refactored code.)

(This pull request is a rebased version of PR #7524, which went stale due to recent unrelated changes to num libraries.)
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 12, 2021
…r=xFrednet

fix bug on mutable ref

fixes: rust-lang#7524

This PR is related to issue rust-lang#7524
changelog:  [`extend_with_drain`] Improve code suggestion for mutable and immutable references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change range_rev to be inclusive on the low end

3 participants