Struct shadow_shim_helper_rs::rootedcell::rc::RootedRc

source ·
pub struct RootedRc<T> { /* private fields */ }
Expand description

Analagous to std::rc::Rc. In particular like std::rc::Rc and unlike std::sync::Arc, it doesn’t perform any atomic operations internally, making it relatively inexpensive

Unlike std::rc::Rc, this type Send and Sync if T is. This is safe because the owner is required to prove ownership of the associated Root to perform any sensitive operations.

Instances must be destroyed explicitly, using RootedRc::explicit_drop, RootedRc::explicit_drop_recursive, or RootedRc::into_inner. These validate that the Root is held before manipulating reference counts, etc.

Dropping RootedRc without calling one of these methods results in a panic in debug builds, or leaking the object in release builds.

Implementations§

source§

impl<T> RootedRc<T>

source

pub fn new(root: &Root, val: T) -> Self

Creates a new object associated with root.

source

pub fn downgrade(this: &Self, root: &Root) -> RootedRcWeak<T>

Create a weak reference.

We use fully qualified syntax here for consistency with Rc and Arc and to avoid name conflicts with T’s methods.

source

pub fn clone(&self, root: &Root) -> Self

Like Clone::clone, but requires that the corresponding Root is held.

Intentionally named clone to shadow Self::deref()::clone().

Panics if root is not the associated Root.

source

pub fn into_inner(this: Self, root: &Root) -> Option<T>

Drop the RootedRc, and return the inner value if this was the last strong reference.

source

pub fn explicit_drop_recursive( self, root: &Root, param: &T::ExplicitDropParam, ) -> Option<T::ExplicitDropResult>
where T: ExplicitDrop,

Drops self, and if self was the last strong reference, call ExplicitDrop::explicit_drop on the internal value.

Trait Implementations§

source§

impl<T> Deref for RootedRc<T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> ExplicitDrop for RootedRc<T>

source§

fn explicit_drop( self, root: &Self::ExplicitDropParam, ) -> Self::ExplicitDropResult

If T itself implements ExplicitDrop, consider RootedRc::explicit_drop_recursive instead to call it when dropping the last strong reference.

source§

type ExplicitDropParam = Root

source§

type ExplicitDropResult = ()

Auto Trait Implementations§

§

impl<T> Freeze for RootedRc<T>

§

impl<T> !RefUnwindSafe for RootedRc<T>

§

impl<T> Send for RootedRc<T>
where T: Sync + Send,

§

impl<T> Sync for RootedRc<T>
where T: Sync + Send,

§

impl<T> Unpin for RootedRc<T>

§

impl<T> !UnwindSafe for RootedRc<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> NoTypeInference for T

source§

type This = T

source§

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

source§

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 T
where U: TryFrom<T>,

source§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V