Uh oh!
There was an error while loading. Please reload this page.
Add unstable VecDeque::rotate_{left|right} - #56842
Conversation
rust-highfive
commented
Dec 15, 2018
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
dtolnay
commented
Dec 15, 2018
This does not hit the #30459 RTL naming issue right? The implementation looks good to me. r? @alexcrichton for another look at the unsafe code. |
scottmcm
commented
Dec 16, 2018
I believe this doesn't hit the #30459 RTL issue because it's not on text, and thus is like the I've pushed a new commit with a claim for why this is safe; please double-check it. |
ollie27
commented
Dec 16, 2018
alexcrichton
commented
Dec 17, 2018
I'm not super familiar with the implementation of It's true that |
scottmcm
commented
Dec 17, 2018
I'll add some more tests. Since |
CryZe
commented
Dec 17, 2018
rotate_to_front and rotate_to_back would be ambiguous anyway. The problem here is your viewpoint. Rotating to the back moves all the elements inside the VecDeque from the front to the back, but the ones that fall out of the back get moved to the front. So they traveled from the back to the front, even though the method name suggested we move from the front to the back. That's because rotating from point A to point B on a circle can be done either clockwise or counter clockwise. So from_a_to_b is ambiguous. So the naming would either have to be clockwise / counter_clockwise or left / right to not be ambiguous. |
alexcrichton
commented
Dec 17, 2018
Ah if |
This comment has been minimized.
This comment has been minimized.
d58b37b to
cbe9abbComparealexcrichton
commented
Dec 19, 2018
@bors: r+ |
bors
commented
Dec 19, 2018
📌 Commit cbe9abb has been approved by |
…chton
Add unstable VecDeque::rotate_{left|right}
Like the ones on slices, but more efficient because vecdeque is a circular buffer.
Issue that proposed this: rust-lang#56686
~~:bomb: Please someone look very carefully at the `unsafe` in this! The `wrap_copy` seems to be exactly what this method needs, and the `len` passed to it is never more than half the length of the deque, but I haven't managed to prove to myself that it's correct :bomb:~~ I think I proved that this code meets the requirement of the unsafe code it's calling; please double-check, of course.bors
commented
Dec 20, 2018
⌛ Testing commit cbe9abb with merge 04cfa08155cf0c5d7bdec75b7f0f7fd8d8bb4526... |
bors
commented
Dec 20, 2018
💔 Test failed - status-travis |
rust-highfive
commented
Dec 20, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
alexcrichton
commented
Dec 20, 2018
…chton
Add unstable VecDeque::rotate_{left|right}
Like the ones on slices, but more efficient because vecdeque is a circular buffer.
Issue that proposed this: rust-lang#56686
~~:bomb: Please someone look very carefully at the `unsafe` in this! The `wrap_copy` seems to be exactly what this method needs, and the `len` passed to it is never more than half the length of the deque, but I haven't managed to prove to myself that it's correct :bomb:~~ I think I proved that this code meets the requirement of the unsafe code it's calling; please double-check, of course.Rollup of 20 pull requests Successful merges: - #56802 (Add DoubleEndedIterator::nth_back) - #56842 (Add unstable VecDeque::rotate_{left|right}) - #56869 (Reduce search-index.js size) - #56887 (Disable field reordering for repr(int).) - #56892 (rustc: Update Clang used to build LLVM on Linux) - #56909 (static eval: Do not ICE on layout size overflow) - #56914 (Ignore ui/target-feature-gate on sparc, sparc64, powerpc, powerpc64 and powerpc64le) - #56917 (Simplify MIR generation for logical operations) - #56919 (Remove a wrong multiplier on relocation offset computation) - #56933 (Add --progress to git submodule commands in x.py) - #56941 (deny intra-doc link resolution failures in libstd) - #56964 (Remove `TokenStream::JointTree`.) - #56970 (Mem uninit doc ptr drop) - #56973 (make basic CTFE tracing available on release builds) - #56979 (Adding unwinding support for x86_64_fortanix_unknown_sgx target.) - #56981 (miri: allocation is infallible) - #56984 (A few tweaks to dropck_outlives) - #56989 (Fix compiletest `trim` deprecation warnings) - #56992 (suggest similar lint names for unknown lints) - #57002 (Stabilize Vec(Deque)::resize_with) Failed merges: r? @ghost
Rollup of 20 pull requests Successful merges: - #56802 (Add DoubleEndedIterator::nth_back) - #56842 (Add unstable VecDeque::rotate_{left|right}) - #56869 (Reduce search-index.js size) - #56887 (Disable field reordering for repr(int).) - #56892 (rustc: Update Clang used to build LLVM on Linux) - #56909 (static eval: Do not ICE on layout size overflow) - #56914 (Ignore ui/target-feature-gate on sparc, sparc64, powerpc, powerpc64 and powerpc64le) - #56917 (Simplify MIR generation for logical operations) - #56919 (Remove a wrong multiplier on relocation offset computation) - #56933 (Add --progress to git submodule commands in x.py) - #56941 (deny intra-doc link resolution failures in libstd) - #56964 (Remove `TokenStream::JointTree`.) - #56970 (Mem uninit doc ptr drop) - #56973 (make basic CTFE tracing available on release builds) - #56979 (Adding unwinding support for x86_64_fortanix_unknown_sgx target.) - #56981 (miri: allocation is infallible) - #56984 (A few tweaks to dropck_outlives) - #56989 (Fix compiletest `trim` deprecation warnings) - #56992 (suggest similar lint names for unknown lints) - #57002 (Stabilize Vec(Deque)::resize_with) Failed merges: r? @ghost
…chton
Add unstable VecDeque::rotate_{left|right}
Like the ones on slices, but more efficient because vecdeque is a circular buffer.
Issue that proposed this: rust-lang#56686
~~:bomb: Please someone look very carefully at the `unsafe` in this! The `wrap_copy` seems to be exactly what this method needs, and the `len` passed to it is never more than half the length of the deque, but I haven't managed to prove to myself that it's correct :bomb:~~ I think I proved that this code meets the requirement of the unsafe code it's calling; please double-check, of course.bors
commented
Dec 22, 2018
Add unstable VecDeque::rotate_{left|right}
Like the ones on slices, but more efficient because vecdeque is a circular buffer.
Issue that proposed this: #56686
~~:bomb: Please someone look very carefully at the `unsafe` in this! The `wrap_copy` seems to be exactly what this method needs, and the `len` passed to it is never more than half the length of the deque, but I haven't managed to prove to myself that it's correct :bomb:~~ I think I proved that this code meets the requirement of the unsafe code it's calling; please double-check, of course.bors
commented
Dec 22, 2018
☀️ Test successful - status-appveyor, status-travis |
Like the ones on slices, but more efficient because vecdeque is a circular buffer.
Issue that proposed this: #56686
💣 Please someone look very carefully at theI think I proved that this code meets the requirement of the unsafe code it's calling; please double-check, of course.unsafein this! Thewrap_copyseems to be exactly what this method needs, and thelenpassed to it is never more than half the length of the deque, but I haven't managed to prove to myself that it's correct 💣