Implemented in https://github.com/rust-lang/rust/pull/41670; merged 2017-06-02.
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 Rubyrotate_left
+rotate_right
bring_to_front
, like in Dslide
, 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 rightrotate_left
and rotate_right
are used in Rust for bitwise rotationThe 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 pr: https://github.com/rust-lang/rust/pull/48450
stabilization pull request just merged, so i _think_ this can be closed now
Most helpful comment
I suggest renaming the method from
rotate
torotate_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 arotate_right
method.)