#[repr(transparent)]
pub struct NotNull<T, const A: u8, const S: bool, const V: u8>(_);
Expand description
A non-null pointer that we stole the high bits off.
T: type pointed to.
V: number of bits to steal directly by masking them off.
A: number of bits to steal based on the alignment requirements of T.
impl<T: Sized, const A: u8, const S: bool, const V: u8> NotNull<T, A, S, V>
Creates a new Ointer from a presumed legitimate pointer.
- T’s alignment must enable stealing A bits.
- The high bits (sign upwards) must match a stack pointer’s high bits.
- If compiling for a 64bit arch, V must be at most 25.
- If compiling for a non-64bit arch, V must be 0.
These invariants are checked with debug_assert
only, hence
unsafe
. The usual caveats of pointers apply.
Returns the stolen bits in the high pos.
pub fn steal(self, bits: usize) -> Self
Takes a value from the high bits of the provided usize and
steals them from the ointer.
Get the pointer without the stolen bits
impl<T: Clone, const A: u8, const S: bool, const V: u8> Clone for NotNull<T, A, S, V>
Performs copy-assignment from source
. Read more
impl<T: Debug, const A: u8, const S: bool, const V: u8> Debug for NotNull<T, A, S, V>
Formats the value using the given formatter. Read more
fn eq(&self, other: &NotNull<T, A, S, V>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &NotNull<T, A, S, V>) -> bool
This method tests for !=
.
impl<T: Copy, const A: u8, const S: bool, const V: u8> Copy for NotNull<T, A, S, V>
impl<T: Eq, const A: u8, const S: bool, const V: u8> Eq for NotNull<T, A, S, V>
impl<T, const A: u8, const S: bool, const V: u8> !Send for NotNull<T, A, S, V>
impl<T, const A: u8, const S: bool, const V: u8> !Sync for NotNull<T, A, S, V>
impl<T, const A: u8, const S: bool, const V: u8> Unpin for NotNull<T, A, S, V>
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.