Skip to main content

TaggedNonNull

Struct TaggedNonNull 

Source
pub struct TaggedNonNull<T: ?Sized>(/* private fields */);
Expand description

A [NonNull<T>] pointer with a numerical tag.

The tag is split between the low alignment bits of the inner type, and the high order bits that are free due to the architecture virtual address width.

Implementations§

Source§

impl<T> TaggedNonNull<T>

Source

pub const TAG_HIGH_BITS: u32 = 16

Source

pub const TAG_LOW_BITS: u32

Source

pub const MAXIMUM_TAG: usize

The (architecture- and type-dependent) maximum value the tag can hold.

Source

pub fn new(ptr: NonNull<T>, tag: usize) -> Self

Create a new TaggedNonNull with the given tag.

Source

pub fn as_ptr(&self) -> NonNull<T>

Extract the pointer portion of the TaggedNonNull.

Source

pub fn tag(&self) -> usize

Extract the tag portion of the TaggedNonNull.

Source

pub fn addr_eq(&self, other: &Self) -> bool

Compares the addresses of the two pointers for equality, ignoring the tag value.

Source

pub fn as_tagged_ptr(&self) -> NonNull<T>

Source

pub fn from_tagged_ptr(ptr: NonNull<T>) -> Self

Trait Implementations§

Source§

impl<T: Clone + ?Sized> Clone for TaggedNonNull<T>

Source§

fn clone(&self) -> TaggedNonNull<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy + ?Sized> Copy for TaggedNonNull<T>

Source§

impl<T: Debug + ?Sized> Debug for TaggedNonNull<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq + ?Sized> Eq for TaggedNonNull<T>

Source§

impl<T: Hash + ?Sized> Hash for TaggedNonNull<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
Source§

impl<T: Ord + ?Sized> Ord for TaggedNonNull<T>

Source§

fn cmp(&self, other: &TaggedNonNull<T>) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0 (const: unstable)§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable)§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable)§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<T: PartialEq + ?Sized> PartialEq for TaggedNonNull<T>

Source§

fn eq(&self, other: &TaggedNonNull<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable)§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialOrd + ?Sized> PartialOrd for TaggedNonNull<T>

Source§

fn partial_cmp(&self, other: &TaggedNonNull<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable)§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable)§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable)§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable)§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Pointer for TaggedNonNull<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: PartialEq + ?Sized> StructuralPartialEq for TaggedNonNull<T>

Auto Trait Implementations§

§

impl<T> !Send for TaggedNonNull<T>

§

impl<T> !Sync for TaggedNonNull<T>

§

impl<T> Freeze for TaggedNonNull<T>
where NonNull<T>: Freeze, T: ?Sized,

§

impl<T> RefUnwindSafe for TaggedNonNull<T>
where NonNull<T>: RefUnwindSafe, T: ?Sized,

§

impl<T> Unpin for TaggedNonNull<T>
where NonNull<T>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for TaggedNonNull<T>
where NonNull<T>: UnsafeUnpin, T: ?Sized,

§

impl<T> UnwindSafe for TaggedNonNull<T>
where NonNull<T>: UnwindSafe, T: ?Sized,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.