[][src]Trait zerogc::GcRef

pub trait GcRef<'gc, T: GcSafe + ?Sized + 'gc>: GcSafe + Copy + Deref<Target = &'gc T> {
    type System: GcSystem;
    fn value(&self) -> &'gc T;

    unsafe fn as_raw_ptr(&self) -> *mut T { ... }
}

A garbage collected pointer to a value.

This is the equivalent of a garbage collected smart-pointer. It's so smart, you can even coerce it to a reference bound to the lifetime of the GarbageCollectorRef. However, all those references are invalidated by the borrow checker as soon as your reference to the collector reaches a safepoint. The objects can only survive garbage collection if they live in this smart-pointer.

The smart pointer is simply a guarantee to the garbage collector that this points to a garbage collected object with the correct header, and not some arbitrary bits that you've decided to heap allocate.

Associated Types

type System: GcSystem

The type of the garbage collection system that created this pointer

Loading content...

Required methods

fn value(&self) -> &'gc T

The value of the underlying pointer

Loading content...

Provided methods

unsafe fn as_raw_ptr(&self) -> *mut T

Loading content...

Implementors

Loading content...