pub(crate) trait IntoRoot<T> {
// Required method
unsafe fn into_root(self) -> T;
}
Expand description
Helper trait to break the dependency between an object and the lifetimes of it’s traceable children. If This trait is implemented, than the object can be traced by the garbage collector. Once it becomes rooted, it as well as all of it’s tracable children will be live until it is unrooted. This essentially makes any lifetimes of a tracable objects meaningless. They can be anything, including ’static. When an object is removed from a root it will be given the proper lifetime again. Care must be taken to ensure that any lifetimes that are changed only belong to traceable objects. Object can contain lifetimes parameters for both traceable and untracable children, and only the traceable children’s lifetimes can be changed.
On top of scrubbing the lifetimes, this trait can also do a transformation
of the underlying type for convenience, similar to calling Into::into
.