Struct boa_gc::Ephemeron

source ·
pub struct Ephemeron<K: Trace + ?Sized + 'static, V: Trace + 'static> { /* private fields */ }
Expand description

A key-value pair where the value becomes unaccesible when the key is garbage collected.

You can read more about ephemerons on:

Implementations§

source§

impl<K: Trace + ?Sized, V: Trace + Clone> Ephemeron<K, V>

source

pub fn value(&self) -> Option<V>

Gets the stored value of this Ephemeron, or None if the key was already garbage collected.

This needs to return a clone of the value because holding a reference to it between garbage collection passes could drop the underlying allocation, causing an Use After Free.

source

pub fn key(&self) -> Option<Gc<K>>

Gets the stored key of this Ephemeron, or None if the key was already garbage collected.

source

pub fn has_value(&self) -> bool

Checks if the Ephemeron has a value.

source§

impl<K: Trace + ?Sized, V: Trace> Ephemeron<K, V>

source

pub fn new(key: &Gc<K>, value: V) -> Self

Creates a new Ephemeron.

source

pub fn ptr_eq(this: &Self, other: &Self) -> bool

Returns true if the two Ephemerons point to the same allocation.

Trait Implementations§

source§

impl<K: Trace + ?Sized, V: Trace> Clone for Ephemeron<K, V>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<K: Debug + Trace + ?Sized + 'static, V: Debug + Trace + 'static> Debug for Ephemeron<K, V>

source§

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

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

impl<K: Trace + ?Sized, V: Trace> Drop for Ephemeron<K, V>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<K: Trace + ?Sized, V: Trace> Finalize for Ephemeron<K, V>

source§

fn finalize(&self)

Cleanup logic for a type.
source§

impl<T: Trace> From<Ephemeron<T, ()>> for WeakGc<T>

source§

fn from(inner: Ephemeron<T, ()>) -> Self

Converts to this type from the input type.
source§

impl<K: Trace + ?Sized, V: Trace> Trace for Ephemeron<K, V>

source§

unsafe fn trace(&self, _tracer: &mut Tracer)

Marks all contained Gcs. Read more
source§

unsafe fn trace_non_roots(&self)

Trace handles located in GC heap, and mark them as non root. Read more
source§

fn run_finalizer(&self)

Runs Finalize::finalize on this object and all contained subobjects.

Auto Trait Implementations§

§

impl<K, V> !RefUnwindSafe for Ephemeron<K, V>

§

impl<K, V> !Send for Ephemeron<K, V>

§

impl<K, V> !Sync for Ephemeron<K, V>

§

impl<K: ?Sized, V> Unpin for Ephemeron<K, V>

§

impl<K, V> !UnwindSafe for Ephemeron<K, V>

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

§

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

§

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

§

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.