Tracking Issue for raw slice getters (slice_ptr_get) · Issue #74265 · rust-lang/rust (original) (raw)
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 *mut [T] { pub const fn as_mut_ptr(self) -> *mut T {} pub unsafe fn get_unchecked_mut(self, index: I) -> *mut I::Output where I: SliceIndex<[T]>; }
impl *const [T] { pub const fn as_ptr(self) -> *const T {} pub unsafe fn get_unchecked(self, index: I) -> *const I::Output where I: SliceIndex<[T]>; }
impl NonNull<[T]> { pub const fn as_non_null_ptr(self) -> NonNull {} pub const fn as_mut_ptr(self) -> *mut T {} pub unsafe fn get_unchecked_mut(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
: Add as_mut_ptr to NonNull<[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)