#[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.
Implementations§
source§impl<T: Sized, const A: u8, const S: bool, const V: u8> NotNull<T, A, S, V>
impl<T: Sized, const A: u8, const S: bool, const V: u8> NotNull<T, A, S, V>
sourcepub unsafe fn new(ptr: NonNull<T>) -> Self
pub unsafe fn new(ptr: NonNull<T>) -> Self
Creates a new Ointer from a presumed legitimate pointer.
Safety
- 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.
sourcepub unsafe fn new_stealing(ptr: NonNull<T>, bits: usize) -> Self
pub unsafe fn new_stealing(ptr: NonNull<T>, bits: usize) -> Self
sourcepub fn steal(self, bits: usize) -> Self
pub fn steal(self, bits: usize) -> Self
Takes a value from the high bits of the provided usize and steals them from the ointer.
sourcepub fn as_non_null(self) -> NonNull<T>
pub fn as_non_null(self) -> NonNull<T>
Get the pointer without the stolen bits
Trait Implementations§
source§impl<T, const A: u8, const S: bool, const V: u8> PartialEq<NotNull<T, A, S, V>> for NotNull<T, A, S, V>
impl<T, const A: u8, const S: bool, const V: u8> PartialEq<NotNull<T, A, S, V>> for NotNull<T, A, S, V>
impl<T: Sized, const A: u8, const S: bool, const V: u8> Copy for NotNull<T, A, S, V>
impl<T, const A: u8, const S: bool, const V: u8> Eq for NotNull<T, A, S, V>
Auto Trait Implementations§
impl<T, const A: u8, const S: bool, const V: u8> RefUnwindSafe for NotNull<T, A, S, V>where T: RefUnwindSafe,
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>where T: Unpin,
impl<T, const A: u8, const S: bool, const V: u8> UnwindSafe for NotNull<T, A, S, V>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more