Struct WithHeader

#[repr(transparent)]
pub(in ::boxed::thin) struct WithHeader<H>(pub(in ::boxed::thin) NonNull<u8>, pub(in ::boxed::thin) PhantomData<H>);

A pointer to type-erased data, guaranteed to either be:

  1. NonNull::dangling(), in the case where both the pointee (T) and metadata (H) are ZSTs.
  2. A pointer to a valid T that has a header H directly before the pointed-to location.

Fields

0: NonNull<u8>
1: PhantomData<H>

Implementations

impl<H> WithHeader<H>

fn new<T>(header: H, value: T) -> WithHeader<H>
fn try_new<T>(header: H, value: T) -> Result<WithHeader<H>, AllocError>

Non-panicking version of new. Any error is returned as Err(core::alloc::AllocError).

fn new_unsize_zst<Dyn, T>(value: T) -> WithHeader<H>
where
    Dyn: Pointee<Metadata = H> + ?Sized,
    T: Unsize<Dyn>,
unsafe fn drop<T: ?Sized>(&self, value: *mut T)
fn header(&self) -> *mut H
fn value(&self) -> *mut u8
const fn header_size() -> usize
fn alloc_layout(value_layout: Layout) -> Result<(Layout, usize), LayoutError>

Auto Trait Implementations

impl<H> !Send for WithHeader<H>

impl<H> !Sync for WithHeader<H>

impl<H> Freeze for WithHeader<H> where PhantomData<H>: Freeze,

impl<H> RefUnwindSafe for WithHeader<H> where PhantomData<H>: RefUnwindSafe,

impl<H> Unpin for WithHeader<H> where PhantomData<H>: Unpin,

impl<H> UnsafeUnpin for WithHeader<H> where PhantomData<H>: UnsafeUnpin,

impl<H> UnwindSafe for WithHeader<H> where PhantomData<H>: UnwindSafe,

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for WithHeader<H>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for WithHeader<H> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for WithHeader<H>

impl<T, U> Into<U> for WithHeader<H> 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, U> TryFrom<U> for WithHeader<H> where U: Into<T>,

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

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

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