Type Alias mozjs_sys::jsapi::JS::Heap

source ·
pub type Heap<T> = Heap<T>;

Aliased Type§

struct Heap<T> {
    pub ptr: UnsafeCell<T>,
}

Fields§

§ptr: UnsafeCell<T>

Implementations§

source§

impl<T: GCMethods + Copy> Heap<T>

source

pub fn boxed(v: T) -> Box<Heap<T>>where Heap<T>: Default,

This creates a Box-wrapped Heap value. Setting a value inside Heap object triggers a barrier, referring to the Heap object location, hence why it is not safe to construct a temporary Heap value, assign a non-null value and move it (e.g. typical object construction).

Using boxed Heap value guarantees that the underlying Heap value will not be moved when constructed.

source

pub fn set(&self, v: T)

source

pub fn get(&self) -> T

source

pub fn get_unsafe(&self) -> *mut T

source

pub unsafe fn handle(&self) -> Handle<T>

Retrieves a Handle to the underlying value.

Safety

This is only safe to do on a rooted object (which Heap is not, it needs to be additionally rooted), like RootedGuard, so use this only if you know what you’re doing.

Notes

Since Heap values need to be informed when a change to underlying value is made (e.g. via get()), this does not allow to create MutableHandle objects, which can bypass this and lead to crashes.

Trait Implementations§

source§

impl<T: Debug + GCMethods + Copy> Debug for Heap<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> Default for Heap<*mut T>where *mut T: GCMethods + Copy,

source§

fn default() -> Heap<*mut T>

Returns the “default value” for a type. Read more
source§

impl Default for Heap<Value>

source§

fn default() -> Heap<Value>

Returns the “default value” for a type. Read more
source§

impl<T: GCMethods + Copy> Drop for Heap<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: GCMethods + Copy + PartialEq> PartialEq<Heap<T>> for Heap<T>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.