stdlib.ptr¶
Pointer Utilities
Generated from
v0.60.1. 1 source files, 19 documented symbols.
ptr.xi¶
fn null[T]() -> *T¶
Null pointer of type
*T(escape hatch; never dereference).
- Precondition:
true
fn null_mut[T]() -> *T¶
Null pointer of type
*mut T(escape hatch; never dereference).
- Precondition:
true
fn dangling[T]() -> *T¶
Non-null marker pointer that must never be dereferenced.
- Precondition:
true
fn is_null[T](ptr: *T) -> Bool¶
True when
ptris a null pointer.
fn read[T](ptr: *T) -> T¶
Read the value at
ptr; requires a non-null, valid pointer.
- Precondition:
ptr != null
fn write[T](ptr: *T, value: T)¶
Write
valuetoptr; requires a non-null, valid pointer.
- Precondition:
ptr != null
fn read_volatile[T](ptr: *T) -> T¶
Volatile read at
ptr(no elision/reordering by the backend).
- Precondition:
ptr != null
fn write_volatile[T](ptr: *T, value: T)¶
Volatile write of
valuetoptr.
- Precondition:
ptr != null
fn swap[T](a: *T, b: *T)¶
Swap the values at
aandb; both must be non-null and valid.
- Precondition:
a != null - Precondition:
b != null
fn replace[T](dest: *T, src: T) -> T¶
Replace
*destwithsrc, returning the previous value.
- Precondition:
dest != null - Postcondition:
result == old_value
fn copy[T](src: *T, dst: *T, count: Int)¶
Copy
countvalues fromsrctodst; ranges may overlap.
- Precondition:
src != null - Precondition:
dst != null - Precondition:
count > 0
fn copy_nonoverlapping[T](src: *T, dst: *T, count: Int)¶
Copy
countvalues fromsrctodst; ranges must not overlap.
- Precondition:
src != null - Precondition:
dst != null - Precondition:
count > 0
fn eq[T](a: *T, b: *T) -> Bool¶
Pointer equality (address comparison).
fn offset[T](ptr: *T, count: Int) -> *T¶
Pointer arithmetic:
ptr + countelements.
- Precondition:
ptr != null
fn wrapping_offset[T](ptr: *T, count: Int) -> *T¶
Wrapping pointer arithmetic (no in-bounds requirement).
- Precondition:
true
fn add[T](ptr: *T, count: Int) -> *T¶
ptr + countelements; requires a non-null pointer.
- Precondition:
ptr != null
fn sub[T](ptr: *T, count: Int) -> *T¶
ptr - countelements; requires a non-null pointer.
- Precondition:
ptr != null
fn from_ref[T](r: &T) -> *T¶
Convert a shared reference to a raw pointer (escape hatch).
- Precondition:
true
fn from_mut[T](r: &mut T) -> *T¶
Convert a mutable reference to a raw mutable pointer (escape hatch).
- Precondition:
true