[][src]Struct tagged_box::TaggedPointer

#[repr(transparent)]
pub struct TaggedPointer { /* fields omitted */ }

A pointer that holds a data pointer plus additional data stored as a Discriminant
Note: The discriminant must be <= MAX_DISCRIMINANT, which is feature-dependent

Methods

impl TaggedPointer[src]

pub fn new(ptr: usize, discriminant: Discriminant) -> Self[src]

Create a new tagged pointer from a pointer and a discriminant

Panics

Panics if discriminant is greater than MAX_DISCRIMINANT or if ptr is greater than MAX_POINTER_VALUE

pub unsafe fn new_unchecked(ptr: usize, discriminant: Discriminant) -> Self[src]

Create a new tagged pointer from a pointer and a discriminant without checking invariance

Safety

discriminant must be <= MAX_DISCRIMINANT and pointer must be <= MAX_POINTER_VALUE

pub const fn discriminant(self) -> Discriminant[src]

Fetches the discriminant of the tagged pointer

pub unsafe fn as_ref<T>(&self) -> &T[src]

Gains a reference to the inner value of the pointer

Safety

The pointer given to TaggedPointer::new must be properly aligned and non-null

pub unsafe fn as_mut_ref<T>(&mut self) -> &mut T[src]

Gains a mutable reference to the inner value of the pointer

Safety

The pointer given to TaggedPointer::new must be properly aligned and non-null

pub const fn as_usize(self) -> usize[src]

Returns the pointer as a usize, removing the discriminant

pub const fn as_raw_usize(self) -> usize[src]

Returns the raw tagged pointer, without removing the discriminant

Warning

Attempting to dereference this usize will not point to valid memory!

pub const fn as_ptr<T>(self) -> *const T[src]

Converts a tagged pointer into a raw pointer, removing the discriminant

pub fn as_mut_ptr<T>(self) -> *mut T[src]

Converts a tagged pointer into a raw pointer, removing the discriminant

pub fn store_discriminant(pointer: usize, discriminant: Discriminant) -> usize[src]

Store a Discriminant into a tagged pointer

Panics

Panics if discriminant is greater than MAX_DISCRIMINANT or if ptr is greater than MAX_POINTER_VALUE

pub unsafe fn store_discriminant_unchecked(
    pointer: usize,
    discriminant: Discriminant
) -> usize
[src]

Store a Discriminant into a tagged pointer without any checks

Safety

discriminant must be <= MAX_DISCRIMINANT and pointer must be <= MAX_POINTER_VALUE

pub const fn fetch_discriminant(pointer: usize) -> Discriminant[src]

Fetch a Discriminant from a tagged pointer

pub const fn strip_discriminant(pointer: usize) -> usize[src]

Strip the Discriminant from a tagged pointer, returning only the valid pointer as a usize

Trait Implementations

impl Binary for TaggedPointer[src]

impl Clone for TaggedPointer[src]

impl Copy for TaggedPointer[src]

impl Debug for TaggedPointer[src]

impl Eq for TaggedPointer[src]

impl Hash for TaggedPointer[src]

impl LowerHex for TaggedPointer[src]

impl Octal for TaggedPointer[src]

impl Ord for TaggedPointer[src]

impl PartialEq<TaggedPointer> for TaggedPointer[src]

impl PartialOrd<TaggedPointer> for TaggedPointer[src]

impl Pointer for TaggedPointer[src]

impl StructuralEq for TaggedPointer[src]

impl StructuralPartialEq for TaggedPointer[src]

impl UpperHex for TaggedPointer[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.