-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullA-sliceArea: `[T]`Area: `[T]`B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-SmallLibs issues that are considered "small" or self-containedLibs issues that are considered "small" or self-containedLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
This is a tracking issue for indexing methods on raw slices: get_unchecked(_mut)
and as_(mut_/non_null_)ptr
on raw slices (mutable and const raw pointers and NonNull
).
The feature gate for the issue is #![feature(slice_ptr_get)]
.
Public API
impl<T> *mut [T] {
pub const fn as_mut_ptr(self) -> *mut T {}
pub unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output where I: SliceIndex<[T]>;
}
impl<T> *const [T] {
pub const fn as_ptr(self) -> *const T {}
pub unsafe fn get_unchecked<I>(self, index: I) -> *const I::Output where I: SliceIndex<[T]>;
}
impl<T> NonNull<[T]> {
pub const fn as_non_null_ptr(self) -> NonNull<T> {}
pub const fn as_mut_ptr(self) -> *mut T {}
pub unsafe fn get_unchecked_mut<I>(self, index: I) -> NonNull<I::Output> where I: SliceIndex<[T]>;
}
History / Steps
- Initial PR: add (unchecked) indexing methods to raw (and NonNull) slices #73986
- Add
NonNull::as_mut_ptr
: Addas_mut_ptr
toNonNull<[T]>
#75248 - Final commenting period (FCP)
- Stabilization PR
Open questions
- Potential blockers: rustc performs auto-ref when a raw pointer would be enough #73987, Missing unsizing coercions for raw slice pointers #74679
- Should this use
arbitrary_self_types
(Arbitrary self types v2 rfcs#3519)
stepancheg, luketpeterson and nazar-pcshepmaster, CPerezz, josephlr, luojia65, TobTobXX and 9 more
Metadata
Metadata
Assignees
Labels
A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullA-sliceArea: `[T]`Area: `[T]`B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-SmallLibs issues that are considered "small" or self-containedLibs issues that are considered "small" or self-containedLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.