doc.rust-lang.org
pub const unsafe fn write_unaligned(self, val: T)
Overwrites a memory location with the given value without reading or dropping the old value.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn write_bytes(self, val: u8, count: usize)
Invokes memset on the specified pointer, setting count * size_of::<T>() bytes of memory starting at self to val.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn write(self, val: T)
Overwrites a memory location with the given value without reading or dropping the old value.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn without_provenance(addr: NonZero<usize>) -> Self
Creates a pointer with the given address and no provenance.
associated_function
core
Stable since 1.89.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn with_exposed_provenance(addr: NonZero<usize>) -> Self
Converts an address back to a mutable pointer, picking up some previously 'exposed' provenance.
associated_function
core
Stable since 1.89.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn with_addr(self, addr: NonZero<usize>) -> Self
Creates a new pointer with the given address and the provenance of self.
method
core
Stable since 1.84.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn swap(self, with: NonNull<T>)
Swaps the values at two mutable locations of the same type, without deinitializing either. They may overlap, unlike mem::swap which is otherwise equivalent.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn sub(self, count: usize) -> Self
Subtracts an unsigned offset from a pointer.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn slice_from_raw_parts(data: NonNull<T>, len: usize) -> Self
Creates a non-null raw slice from a thin pointer and a length.
associated_function
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn replace(self, src: T) -> T
Replaces the value at self with src, returning the old value, without dropping either.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub unsafe fn read_volatile(self) -> T
Performs a volatile read of the value from self without moving it. This leaves the memory in self unchanged.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn read_unaligned(self) -> T
Reads the value from self without moving it. This leaves the memory in self unchanged.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn read(self) -> T
Reads the value from self without moving it. This leaves the memory in self unchanged.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn offset_from_unsigned(self, subtracted: NonNull<T>) -> usize
Calculates the distance between two pointers within the same allocation, where it's known that self is equal to or greater than origin. The returned value is in units of T: the distance in bytes is divided by size_of::<T>().
method
core
Stable since 1.87.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn offset_from(self, origin: NonNull<T>) -> isize
Calculates the distance between two pointers within the same allocation. The returned value is in units of T: the distance in bytes divided by size_of::<T>().
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn offset(self, count: isize) -> Self
Adds a signed offset to a pointer.
method
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self
Creates a new NonNull.
associated_function
core
Stable since 1.25.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new(ptr: *mut T) -> Option<Self>
Creates a new NonNull if ptr is non-null.
associated_function
core
Stable since 1.25.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn map_addr(self, f: impl FnOnce(NonZero<usize>) -> NonZero<usize>) -> Self
Creates a new pointer by mapping self's address to a new one, preserving the provenance of self.
method
core
Stable since 1.84.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn len(self) -> usize
Returns the length of a non-null raw slice.
method
core
Stable since 1.63.0
Version 1.100.0-nightly