Skip to main content

Rooted

Struct Rooted 

Source
pub struct Rooted<'s> { /* private fields */ }
Expand description

A GcRef proven rooted for 's — the only input to a &mut Payload accessor.

A Rooted<'s> cannot outlive the NativeScope that produced it, and the accessors’ results cannot outlive the Rooted, so the whole chain is bounded by a scope that is itself in the collector’s root set. An accessor taking a bare GcRef and handing back a &'static mut Payload would say the payload outlives the program, and let a helper keep writing through one across an allocation that reclaimed its owner.

It carries the reference by value, and that is what makes it survive the store’s growth. A Rooted that held a *mut GcRef into NativeRootStore would be the natural shape — Drop could then clear its own slot — and it would be wrong: the store reallocs, so a later root() in any live scope can move the array out from under every Rooted handed out before it. Holding the value instead means growth is invisible here. What the store owes a Rooted is not an address but a promise — that the reference is somewhere in [0, len) for as long as the scope lives — and moving the array does not break that promise.

Implementations§

Source§

impl Rooted<'_>

Source

pub fn get(self) -> GcRef

The underlying reference. Copying it out drops the proof, so this is for passing the value on (as a call argument, as a return value), not for re-deriving a payload reference.

Trait Implementations§

Source§

impl<'s> Clone for Rooted<'s>

Source§

fn clone(&self) -> Rooted<'s>

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

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

Performs copy-assignment from source. Read more
Source§

impl<'s> Copy for Rooted<'s>

Source§

impl<'s> Debug for Rooted<'s>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> !RefUnwindSafe for Rooted<'s>

§

impl<'s> !Send for Rooted<'s>

§

impl<'s> !Sync for Rooted<'s>

§

impl<'s> !UnwindSafe for Rooted<'s>

§

impl<'s> Freeze for Rooted<'s>

§

impl<'s> Unpin for Rooted<'s>

§

impl<'s> UnsafeUnpin for Rooted<'s>

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> CloneToUninit for T
where T: Clone,

Source§

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
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> ToOwned for T
where T: Clone,

Source§

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