macro_rules! safepoint {
($context:ident, $value:expr) => { ... };
}
Expand description
Indicate it’s safe to begin a garbage collection, while keeping the specified root alive.
All other garbage collected pointers that aren’t reachable from the root are invalidated. They have a lifetime that references the GcContext and the borrow checker considers the safepoint a ‘mutation’.
The root is exempted from the “mutation” and rebound to the new lifetime.
Example
let root = zerogc::epsilon::leaked(String::from("potato"));
let root = safepoint!(context, root);
assert_eq!(*root, "potato");
Safety
This macro is completely safe, although it expands to unsafe code internally.