Skip to main content

Module gc

Module gc 

Source
Expand description

GcRef<T> — the GC-managed reference handle.

Phase A/B/C: thin newtype around Rc<T>. Phase D-1e (current): newtype around lua_gc::Gc<T> — Copy under the hood, tracks allocation in the active Heap (via lua_gc::with_current_heap(...)).

Surface kept stable across the swap: new, ptr_eq, identity, strong_count, weak_count, downgrade. Existing code touching gc.0 continues to work — .0 is now Gc<T> instead of Rc<T>.

§Weak refs (D-1)

GcWeak<T> is currently a no-op wrapper: upgrade always returns Some, strong_count always returns 1. Real weak semantics arrive in D-2 when the heap learns to mark weak refs separately. For D-1, weak tables ARE a known semantic gap (see PHASE_D_PLAN.md “Locked Decisions”).

Structs§

GcRef
A GC-managed pointer to a Lua collectable object. Newtype over lua_gc::Gc<T> so callers preserve gc.0-shape access while the backend swaps under them.
GcWeak
A weak handle to a GcRef<T>. Phase D-1 placeholder; D-2 will give this real semantics (None once the referent is swept).