pub unsafe trait TrustedDrop: Trace { }
Expand description

Indicates that a type’s Drop implementation is trusted not to resurrect any garbage collected object.

This is a requirement for a type to be allocated in GcSimpleAlloc, and also for a type to be GcSafe.

Unlike java finalizers, these trusted destructors avoids a second pass to check for resurrected objects. This is important giving the frequency of destructors when interoperating with native code.

The collector is of course free to implement support java-style finalizers in addition to supporting these “trusted” destructors.

Safety

To implement this trait, the type’s destructor must never reference garbage collected pointers that may already be dead and must never resurrect dead objects. The garbage collector may have already freed the other objects before calling this type’s drop function.

Implementations on Foreign Types

Implementors

Double-indirection is completely safe