-
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, NonNullC-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 RFCT-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
Feature gate: #![feature(non_null_convenience)]
This is a tracking issue for convenience methods on NonNull
.
Public API
// core::ptr
impl<T: Sized> NonNull<T> {
pub const unsafe fn offset(self, count: isize) -> NonNull<T>;
pub const unsafe fn add(self, count: usize) -> NonNull<T>;
pub const unsafe fn sub(self, count: usize) -> NonNull<T>;
pub const unsafe fn offset_from(self, origin: NonNull<T>) -> isize;
pub const unsafe fn sub_ptr(self, subtracted: NonNull<T>) -> usize;
pub const unsafe fn read(self) -> T;
pub unsafe fn read_volatile(self) -> T;
pub const unsafe fn read_unaligned(self) -> T;
pub const unsafe fn copy_to(self, dest: NonNull<T>, count: usize);
pub const unsafe fn copy_to_nonoverlapping(self, dest: NonNull<T>, count: usize);
pub const unsafe fn copy_from(self, src: NonNull<T>, count: usize);
pub const unsafe fn copy_from_nonoverlapping(self, src: NonNull<T>, count: usize);
pub const unsafe fn write(self, val: T);
pub const unsafe fn write_bytes(self, val: u8, count: usize);
pub unsafe fn write_volatile(self, val: T);
pub const unsafe fn write_unaligned(self, val: T);
pub unsafe fn replace(self, src: T) -> T;
pub const unsafe fn swap(self, with: NonNull<T>);
pub const fn align_offset(self, align: usize) -> usize;
pub const fn is_aligned(self) -> bool;
}
impl<T: ?Sized> NonNull<T> {
pub const unsafe fn byte_offset(self, count: isize) -> NonNull<T>;
pub const unsafe fn byte_add(self, count: usize) -> NonNull<T>;
pub const unsafe fn byte_sub(self, count: usize) -> NonNull<T>;
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: NonNull<U>) -> isize;
pub unsafe fn drop_in_place(self);
pub const fn is_aligned_to(self, align: usize) -> bool;
}
(I'll fill the API once PR is merged, stand-by...)
Steps / History
- ACP: Expose
add
/sub
/sub_ptr
onNonNull
libs-team#251 - Implementation: Non null convenience ops #117697
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.
Footnotes
rj00a, orzogc and Robbepop
Metadata
Metadata
Assignees
Labels
A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullC-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 RFCT-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.