macro_rules! Rootable {
($gc:lifetime => $root:ty) => { ... };
($root:ty) => { ... };
}Expand description
A convenience macro for quickly creating a type that implements Rootable.
The macro takes a single argument, which should be a generic type with elided lifetimes. When used as a root object, every instance of the elided lifetime will be replaced with the branding lifetime.
#[derive(Collect)]
#[collect(no_drop)]
struct MyRoot<'gc> {
ptr: Gc<'gc, i32>,
}
type MyArena = Arena<Rootable![MyRoot<'_>]>;
// If desired, the branding lifetime can also be explicitely named:
type MyArena2 = Arena<Rootable!['gc => MyRoot<'gc>]>;The macro can also be used to create implementations of Rootable that use other generic
parameters, though in complex cases it may be better to implement Rootable directly.
#[derive(Collect)]
#[collect(no_drop)]
struct MyGenericRoot<'gc, T> {
ptr: Gc<'gc, T>,
}
type MyGenericArena<T> = Arena<Rootable![MyGenericRoot<'_, T>]>;