-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Tracking issue for copy_within #54236
Comments
@alexcrichton what do the next steps look like for something like this? How do we "decide" on an API? :) |
@oconnor663 the process here is somewhat informal, but after the API has been in nightly for some time it's renominated for stabilization with any open questions, and at that point the libs team all signs off on the stabilization. To that end it's basically "let this sit for awhile and gain feedback", and then after awhile has passed it can be proposed to be stabilized |
We won't be able to land this in master for probably several major Rust versions, but it's nice to see it working. Tracking issue: rust-lang/rust#54236
FWIW, I tried this out in ring and here's my feedback:
|
Thanks for trying it out.
|
I have my own API that is like |
I don't imagine it would make sense to hoist the bounds checking requirement up to the caller, and just have ring propagate the panic if the bounds are wrong? I guess the question is whether any of the callers are expected to have a fallback, or whether bad bounds are more likely to be programmer error. |
There are lots of possibilities. This isn't the only API in libstd that has only a panicking version so if that's what libstd people like, I would just carry on as-is. |
Yeah I was definitely working by analogy with |
FWIW this is desired by Ropey crate. Currently unsafe code is used to achieve this. |
@briansmith Adding The arguments for a non-panicking version also sound good to me. Perhaps even instead of, not in addition to what’s implemented today. And users that want panic can call What API should this have? Perhaps a The other API that does non-panicky bounds checking of a range argument is |
@SimonSapin I put an I feel like I remember some General Guidance from many years ago, when there was a big cleanup going on in the stdlib, about when to have panicking vs option/result APIs or when to have both. Does anyone remember where that was or what the consensus was there? |
@Shnatsel this function is available in the tiny |
Has it been a while yet? :) I'd like to use this if stabilized. |
Filed a stabilization PR at #61398. |
…monSapin Stabilize copy_within Closes rust-lang#54236.
…monSapin Stabilize copy_within Closes rust-lang#54236.
Rust PR: #53652
Standalone implementation: https://github.com/oconnor663/copy_in_place
Summary: This is a safe wrapper around
ptr::copy
, for regions within a single slice. Previously, safe in-place copying was only available as a side effect ofVec::drain
.Open questions: @SimonSapin had a proposal for an alternative API using ranges. Here's an example PR along those lines: oconnor663/copy_in_place#1
The text was updated successfully, but these errors were encountered: