pub trait Finalize {
// Provided method
fn finalize(&self) { ... }
}Expand description
Trait to finalize objects before freeing them.
Must be always implemented for every cycle-collectable object, even when finalization is disabled, to avoid cross-crate incompatibilities.
When finalization is disabled, the finalize method will never be called.
§Derive macro
The Finalize derive macro can be used to implement an empty finalizer:
#[derive(Finalize)]
struct Foo {
// ...
}Provided Methods§
Sourcefn finalize(&self)
fn finalize(&self)
The finalizer, which is called after an object becomes garbage and before droping it.
By default, objects are finalized only once. Use the method Cc::finalize_again to make finalization happen again for a certain object.
Also, objects created during the execution of a finalizer are not automatically finalized.
§Default implementation
The default implementation is empty.