pub struct LuaLClosure {
pub proto: GcRef<LuaProto>,
pub upvals: Box<[Cell<GcRef<UpVal>>]>,
}Fields§
§proto: GcRef<LuaProto>§upvals: Box<[Cell<GcRef<UpVal>>]>Each upvalue slot is held in a Cell so that debug.upvaluejoin
can replace an entry with another closure’s slot without rebuilding
the (shared) closure. GcRef<UpVal> is Copy (thin wrapper over
Gc<UpVal>), so a plain Cell is sufficient and skips RefCell
borrow tracking on every upvalue read — critical for the
upvalue_get hot path.
The slice is Box<[_]>, not Vec<_>: the upvalue count is fixed at
closure creation (proto.upvalues.len()) and never grows or shrinks
afterwards (set_upval is a Cell::set into an existing slot, not a
resize). Dropping the Vec capacity word shrinks LuaLClosure by one
pointer and makes buffer_bytes an exact GC-accounting figure.
Implementations§
Source§impl LuaLClosure
impl LuaLClosure
pub fn placeholder() -> Self
Sourcepub fn upval(&self, i: usize) -> GcRef<UpVal>
pub fn upval(&self, i: usize) -> GcRef<UpVal>
Returns the upvalue slot at index i. Cheap (Copy of a one-pointer
GcRef<UpVal>).
Sourcepub fn set_upval(&self, i: usize, new: GcRef<UpVal>)
pub fn set_upval(&self, i: usize, new: GcRef<UpVal>)
Replaces the upvalue slot at index i with new. Used by
debug.upvaluejoin to share an upvalue between two closures.
Sourcepub fn buffer_bytes(&self) -> usize
pub fn buffer_bytes(&self) -> usize
Bytes owned outside the GcBox header/object allocation.
Box<[_]> has no separate capacity; len is the exact slot count,
which is also the faithful GC-accounting figure.
Trait Implementations§
Source§impl Debug for LuaLClosure
impl Debug for LuaLClosure
Source§impl Trace for LuaLClosure
LuaLClosure — Lua closure carrying a Proto and its captured upvalues.
impl Trace for LuaLClosure
LuaLClosure — Lua closure carrying a Proto and its captured upvalues.
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Heap::type_name_count). Collector behavior must not branch on
this. The default covers container blanket impls, which are never
GC-boxed directly; concrete runtime types override it with
std::any::type_name::<Self>().