pub trait Udata51Probe: Any {
// Required methods
fn is_alive(&self) -> bool;
fn as_any(&self) -> &dyn Any;
}Expand description
A Lua 5.1 collect-time finalizability probe for a single userdata.
Lua 5.1 decides which userdata need finalization at collection time, not
at setmetatable time: luaC_separateudata (lgc.c) walks every
userdata and, for each white non-finalized one, reads its live
metatable for __gc. This is observably different from 5.2+, where
luaC_checkfinalizer makes the decision eagerly at setmetatable and a
__gc added to a shared metatable afterwards never takes effect.
The collector cannot read a userdata’s metatable (a VM concept), so the VM
supplies one probe per userdata. The collector only stores probes and
prunes dead ones via is_alive; the VM drives the
metatable read and the actual finalizer registration. Probes are erased
behind std::any::Any so the VM can downcast back to its concrete type
without the collector naming a VM type.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".