Closed
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
Metadata
Metadata
Assignees
Labels
Area: raw pointers, MaybeUninit, NonNullCategory: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.