Rust: Tracking issue for slice_rotate

Created on 10 May 2017  路  9Comments  路  Source: rust-lang/rust

Implemented in https://github.com/rust-lang/rust/pull/41670; merged 2017-06-02.

B-unstable C-tracking-issue T-libs

Most helpful comment

I suggest renaming the method from rotate to rotate_left; otherwise I have trouble remembering exactly what it does either when writing code or when reading it. (If we do this, it would probably also be logical to add a rotate_right method.)

All 9 comments

I suggest renaming the method from rotate to rotate_left; otherwise I have trouble remembering exactly what it does either when writing code or when reading it. (If we do this, it would probably also be logical to add a rotate_right method.)

Bikeshed:

  • rotate, following Stepanov and McJones, like in C++, also Ruby
  • rotate_left+rotate_right
  • bring_to_front, like in D
  • slide, from Parent, fn(&mut [T], impl RangeArgument, usize) -> Range<usize> (often a nicer signature, but easy to implement using rotate on a subslice, so not necessarily the best primitive)

Edit: Added Ruby

More comparison notes:

  • collections.deque.rotate in Python rotates to the right
  • rotate_left and rotate_right are used in Rust for bitwise rotation

The doc text links to non-free documentation. Can we find a publicly available source to link to?

Opened a pull request for introducing rotate_{left,right}: https://github.com/rust-lang/rust/pull/46777

What's the timeline for stabilizing this?

I think @frewsxcv's PR resolved the questions from the original implementation (naming, return value, and docs), so maybe as soon as someone makes a stabilization PR (for 1.26, I guess?).

stabilization pull request just merged, so i _think_ this can be closed now

Was this page helpful?
0 / 5 - 0 ratings