[][src]Trait zerogc::GcSimpleAlloc

pub unsafe trait GcSimpleAlloc<'gc, T: GcSafe + 'gc>: 'gc {
    type Ref: GcRef<'gc, T>;
    fn alloc(&self, value: T) -> Self::Ref;
}

A simple interface to allocating

Some garbage collectors implement more complex interfaces, so implementing this is optional

Associated Types

type Ref: GcRef<'gc, T>

Loading content...

Required methods

fn alloc(&self, value: T) -> Self::Ref

Allocate the specified object in this garbage collector, binding it to the lifetime of this collector.

The object will never be collected until the next safepoint, which is considered a mutation by the borrow checker and will be statically checked. Therefore, we can statically guarantee the pointers will survive until the next safepoint.

See safepoint! docs on how to properly invoke a safepoint and transfer values across it.

This gives a immutable reference to the resulting object. Once allocated, the object can only be correctly modified with a GcCell

Loading content...

Implementors

Loading content...