[][src]Struct gc_arena::GcCell

pub struct GcCell<'gc, T: 'gc + Collect>(_);

A garbage collected pointer to a type T that may be safely mutated. When a type that may hold Gc pointers is mutated, it may adopt new Gc pointers, and in order for this to be safe this must be accompanied by a call to Gc::write_barrier. This type wraps the given T in a RefCell in such a way that writing to the RefCell is always accompanied by a call to Gc::write_barrier.

Methods

impl<'gc, T: 'gc + Collect> GcCell<'gc, T>[src]

pub fn allocate(mc: MutationContext<'gc, '_>, t: T) -> GcCell<'gc, T>[src]

pub fn ptr_eq(this: GcCell<'gc, T>, other: GcCell<'gc, T>) -> bool[src]

pub fn as_ptr(self) -> *mut T[src]

pub fn read<'a>(&'a self) -> Ref<'a, T>[src]

pub fn try_read<'a>(&'a self) -> Result<Ref<'a, T>, BorrowError>[src]

pub fn write<'a>(&'a self, mc: MutationContext<'gc, '_>) -> RefMut<'a, T>[src]

pub fn try_write<'a>(
    &'a self,
    mc: MutationContext<'gc, '_>
) -> Result<RefMut<'a, T>, BorrowMutError>
[src]

Trait Implementations

impl<'gc, T: 'gc + Collect> Collect for GcCell<'gc, T>[src]

fn needs_trace() -> bool where
    Self: Sized
[src]

As an optimization, if this type can never hold a Gc pointer and trace is unnecessary to call, you may implement this method and return false. The default implementation returns true, signaling that Collect::trace must be called. Read more

impl<'gc, T: Collect + 'gc> Copy for GcCell<'gc, T>[src]

impl<'gc, T: Collect + 'gc> Clone for GcCell<'gc, T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'gc, T: 'gc + Collect + Debug> Debug for GcCell<'gc, T>[src]

Auto Trait Implementations

impl<'gc, T> !Send for GcCell<'gc, T>

impl<'gc, T> !Sync for GcCell<'gc, T>

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]