[−][src]Struct gc_arena::GcCell
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]
&'a self,
mc: MutationContext<'gc, '_>
) -> Result<RefMut<'a, T>, BorrowMutError>
Trait Implementations
impl<'gc, T: 'gc + Collect> Collect for GcCell<'gc, T>
[src]
fn trace(&self, cc: CollectionContext)
[src]
fn needs_trace() -> bool where
Self: Sized,
[src]
Self: Sized,
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(&self) -> 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
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,