Struct UniqueRcUninit

pub(in ::rc) struct UniqueRcUninit<T: ?Sized, A: Allocator> { pub(in ::rc) ptr: NonNull<RcInner<T>>, pub(in ::rc) layout_for_value: Layout, pub(in ::rc) alloc: Option<A> }

A unique owning pointer to a RcInner that does not imply the contents are initialized, but will deallocate it (without dropping the value) when dropped.

This is a helper for [Rc::make_mut()] to ensure correct cleanup on panic. It is nearly a duplicate of UniqueRc<MaybeUninit<T>, A> except that it allows T: !Sized, which MaybeUninit does not.

Fields

ptr: NonNull<RcInner<T>>
layout_for_value: Layout
alloc: Option<A>

Implementations

impl<T: ?Sized, A: Allocator> UniqueRcUninit<T, A>

fn new(for_value: &T, alloc: A) -> UniqueRcUninit<T, A>

Allocates a RcInner with layout suitable to contain for_value or a clone of it.

fn try_new(for_value: &T, alloc: A) -> Result<UniqueRcUninit<T, A>, AllocError>

Allocates a RcInner with layout suitable to contain for_value or a clone of it, returning an error if allocation fails.

fn data_ptr(&mut self) -> *mut T

Returns the pointer to be written into to initialize the Rc.

unsafe fn into_rc(self) -> Rc<T, A>

Upgrade this into a normal Rc.

Safety

The data must have been initialized (by writing to [Self::data_ptr()]).

Trait Implementations

impl<T: ?Sized, A: Allocator> Drop for UniqueRcUninit<T, A>

fn drop(&mut self)

Auto Trait Implementations

impl<T, A> !RefUnwindSafe for UniqueRcUninit<T, A>

impl<T, A> !Send for UniqueRcUninit<T, A>

impl<T, A> !Sync for UniqueRcUninit<T, A>

impl<T, A> !UnwindSafe for UniqueRcUninit<T, A>

impl<T, A> Freeze for UniqueRcUninit<T, A> where NonNull<RcInner<T>>: Freeze, Option<A>: Freeze, T: ?Sized,

impl<T, A> Unpin for UniqueRcUninit<T, A> where NonNull<RcInner<T>>: Unpin, Option<A>: Unpin, T: ?Sized,

impl<T, A> UnsafeUnpin for UniqueRcUninit<T, A> where NonNull<RcInner<T>>: UnsafeUnpin, Option<A>: UnsafeUnpin, T: ?Sized,

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for UniqueRcUninit<T, A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for UniqueRcUninit<T, A> where T: ?Sized,

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

impl<T> SizedTypeProperties for UniqueRcUninit<T, A>

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

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