mozjs::gc

Type Alias MutableHandleId

Source
pub type MutableHandleId<'a> = MutableHandle<'a, jsid>;

Aliased Type§

struct MutableHandleId<'a> {
    pub(crate) ptr: *mut PropertyKey,
    anchor: PhantomData<&'a mut PropertyKey>,
}

Fields§

§ptr: *mut PropertyKey§anchor: PhantomData<&'a mut PropertyKey>

Implementations

Source§

impl<'a, T> MutableHandle<'a, T>

Source

pub unsafe fn from_marked_location(ptr: *mut T) -> Self

Source

pub unsafe fn from_raw(handle: RawMutableHandle<T>) -> Self

Source

pub fn handle(&self) -> Handle<'_, T>

Source

pub(crate) fn new(ptr: &'a mut T) -> Self

Source

pub fn get(&self) -> T
where T: Copy,

Source

pub fn set(&mut self, v: T)
where T: Copy,

Source

pub unsafe fn as_mut<'b>(&'b mut self) -> &'b mut T
where 'a: 'b,

Safety: GC must not run during the lifetime of the returned reference.

Source

pub fn reborrow<'b>(&'b mut self) -> MutableHandle<'b, T>
where 'a: 'b,

Creates a copy of this object, with a shorter lifetime, that holds a mutable borrow on the original object. When you write code that wants to use a MutableHandle more than once, you will typically need to call reborrow on all but the last usage. The same way that you might naively clone a type to allow it to be passed to multiple functions.

This is the same thing that happens with regular mutable references, except there the compiler implicitly inserts the reborrow calls. Until rust gains a feature to implicitly reborrow other types, we have to do it by hand.

Source

pub(crate) fn raw(&mut self) -> RawMutableHandle<T>

Trait Implementations

Source§

impl<'a, T> Deref for MutableHandle<'a, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<'a, T> IntoHandle for MutableHandle<'a, T>

Source§

type Target = T

The type of the handle
Source§

fn into_handle(self) -> RawHandle<T>

Convert this object to a handle.
Source§

impl<'a, T> IntoMutableHandle for MutableHandle<'a, T>

Source§

fn into_handle_mut(self) -> RawMutableHandle<T>

Convert this object to a mutable handle.