[][src]Struct gc_arena::Gc

pub struct Gc<'gc, T: 'gc + Collect> { /* fields omitted */ }

A garbage collected pointer to a type T. Implements Copy, and is implemented as a plain machine pointer. You can only allocate Gc pointers through an Allocator inside an arena type, and through "generativity" such Gc pointers may not escape the arena they were born in or be stored inside TLS. This, combined with correct Collect implementations, means that Gc pointers will never be dangling and are always safe to access.

Methods

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

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

pub fn write_barrier(mc: MutationContext<'gc, '_>, gc: Self)[src]

When implementing Collect on types with internal mutability containing Gc pointers, this method must be used to ensure safe mutability. Safe to call, but only necessary from unsafe code.

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

pub fn as_ptr(gc: Gc<'gc, T>) -> *const T[src]

Trait Implementations

impl<'gc, T: 'gc + Collect> Collect for Gc<'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 Gc<'gc, T>[src]

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

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

Performs copy-assignment from source. Read more

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

type Target = T

The resulting type after dereferencing.

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

Auto Trait Implementations

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

impl<'gc, T> !Sync for Gc<'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]