-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
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-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.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
This is a tracking issue for the len() method on raw slice pointers, which allows to get the length of a raw slice pointer when conversion to a slice reference would be UB (because the pointer is null or unaligned).
It covers the feature gates #![feature(slice_ptr_len)]
and #![feature(const_slice_ptr_len)]
(for const fn).
Public API
impl<T> *mut [T] {
pub const fn len(self) -> usize;
pub const fn is_empty(self) -> bool;
}
impl<T> *const [T] {
pub const fn len(self) -> usize;
pub const fn is_empty(self) -> bool;
}
impl<T> NonNull<[T]> {
pub const fn len(self) -> usize; // Already stable
pub const fn is_empty(self) -> bool;
}
History / Steps
- ptr: introduce len() method on raw slices #71082
- Add
len
andslice_from_raw_parts
toNonNull<[T]>
#71940 - Additional
*mut [T]
methods #95594 - also add is_empty to const raw slices #118231
- Add
NonNull::<[T]>::is_empty
. #122800 - Final commenting period (FCP)
- Stabilization PR
Open questions
- Potential blocker: rustc performs auto-ref when a raw pointer would be enough #73987
TianyiShi2001, mexus, ilyavennik, yvt, stepancheg and 2 morekornelskistanislav-tkach and mexus
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-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.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.