Struct ointers::Ox

source ·
#[repr(transparent)]
pub struct Ox<T, const A: u8, const S: bool, const V: u8>(_, _);
Expand description

A Box 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, const A: u8, const S: bool, const V: u8> Ox<T, A, S, V>

source

pub unsafe fn new(boxed: Box<T>) -> Self

Creates a new Ox from a box.

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.

source

pub unsafe fn new_stealing(boxed: Box<T>, bits: usize) -> Self

Constructor that enables stealing bits.

Safety

Same as new

source

pub fn stolen(&self) -> usize

Returns the stolen bits in the high pos.

source

pub fn steal(&mut self, bits: usize)

Takes a value from the high bits of the provided usize and steals them from the ox.

source

pub fn into_box(self) -> Box<T>

Get the box back without the stolen bits

source

pub fn as_ptr(&self) -> *mut T

Get the box back without the stolen bits

source

pub fn raw(&self) -> usize

Direct access to the underlying data. The pointer it returns may not be valid.

Trait Implementations§

source§

impl<T, const A: u8, const S: bool, const V: u8> Clone for Ox<T, A, S, V>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug, const A: u8, const S: bool, const V: u8> Debug for Ox<T, A, S, V>

source§

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

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

impl<T, const A: u8, const S: bool, const V: u8> Deref for Ox<T, A, S, V>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T, const A: u8, const S: bool, const V: u8> DerefMut for Ox<T, A, S, V>

source§

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

Mutably dereferences the value.
source§

impl<T, const A: u8, const S: bool, const V: u8> Drop for Ox<T, A, S, V>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, const A: u8, const S: bool, const V: u8> Hash for Ox<T, A, S, V>

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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, const A: u8, const S: bool, const V: u8> PartialEq<Ox<T, A, S, V>> for Ox<T, A, S, V>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, const A: u8, const S: bool, const V: u8> Eq for Ox<T, A, S, V>

Auto Trait Implementations§

§

impl<T, const A: u8, const S: bool, const V: u8> RefUnwindSafe for Ox<T, A, S, V>where T: RefUnwindSafe,

§

impl<T, const A: u8, const S: bool, const V: u8> !Send for Ox<T, A, S, V>

§

impl<T, const A: u8, const S: bool, const V: u8> !Sync for Ox<T, A, S, V>

§

impl<T, const A: u8, const S: bool, const V: u8> Unpin for Ox<T, A, S, V>where T: Unpin,

§

impl<T, const A: u8, const S: bool, const V: u8> UnwindSafe for Ox<T, A, S, V>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.