pub trait GcRoots {
// Required method
fn trace_roots(&self, tracer: &mut dyn FnMut(ArenaIndex));
}Expand description
Trait for types that contain GC roots.
Implementors should call tracer for each ArenaIndex that represents
a live GC root. This ensures the garbage collector does not collect
reachable objects.
By centralizing root enumeration in this trait, adding a new
ArenaIndex field to a type will produce a compile-time reminder
(or at least a single, obvious place) to update root tracking, rather
than requiring updates in every GC call-site.
Required Methods§
Sourcefn trace_roots(&self, tracer: &mut dyn FnMut(ArenaIndex))
fn trace_roots(&self, tracer: &mut dyn FnMut(ArenaIndex))
Call tracer once for every ArenaIndex that is a live GC root.