-
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
Additional *mut [T]
methods
#95594
Additional *mut [T]
methods
#95594
Conversation
Split out from rust-lang#94247 This adds the following methods to raw slices that already exist on regular slices * `*mut [T]::is_empty` * `*mut [T]::split_at_mut` * `*mut [T]::split_at_unchecked` These methods reduce the amount of unsafe code needed to migrate ChunksMut and related iterators to raw slices (rust-lang#94247) Co-authored-by:: The 8472 <[email protected]>
e39d006
to
a671fa1
Compare
The implementations of |
Indexing raw slices could be useful, but I think that should go into a separate PR if we want to mirror SliceIndex. Plus we'd still need |
`&mut [T]` implies validity which automatically makes `ptr::add` ok within its bounds. But `*mut [T]` does not. Since we still want the benefits of in-bounds pointer arithmetic `split_at_must` must require the caller to pass valid pointers and therefore it is `unsafe`.
1ee3594
to
b0ca46e
Compare
Hi, this PR has been open for a while with no activity and I think it's blocking me from fixing what I think is a soundness issue in the standard library: #94231 This is just a PR to add new methods behind features so I don't think it should be a lot of work to move this forward, but please let me know if there's something I can do to help. |
@bors r+ |
📌 Commit b0ca46e has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#95594 (Additional `*mut [T]` methods) - rust-lang#97130 (rustdoc: avoid including impl blocks with filled-in generics) - rust-lang#97166 (Move conditions out of recover/report functions.) - rust-lang#97605 (Mention filename in suggestion when it differs from primary span) - rust-lang#97613 (rustdoc: Improve calculation of "Impls on Foreign Types") - rust-lang#97626 (rename PointerAddress → PointerExposeAddress) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Split out from #94247
This adds the following methods to raw slices that already exist on regular slices
*mut [T]::is_empty
*mut [T]::split_at_mut
*mut [T]::split_at_mut_unchecked
These methods reduce the amount of unsafe code needed to migrate
ChunksMut
and related iteratorsto raw slices (#94247)
r? @m-ou-se