-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unstable VecDeque::rotate_{left|right} #56842
Conversation
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
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. |
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. |
I'm not super familiar with the implementation of It's true that |
I'll add some more tests. Since |
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. |
Ah if |
This comment has been minimized.
This comment has been minimized.
d58b37b
to
cbe9abb
Compare
@bors: r+ |
📌 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.
⌛ Testing commit cbe9abb with merge 04cfa08155cf0c5d7bdec75b7f0f7fd8d8bb4526... |
💔 Test failed - status-travis |
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 |
…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.
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.
☀️ 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.unsafe
in this! Thewrap_copy
seems to be exactly what this method needs, and thelen
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 💣