Trait Refcounted

Source
pub unsafe trait Refcounted {
    type Rc: Refcount;

    // Required method
    unsafe fn refcount_metadata(&self) -> <Self::Rc as Refcount>::Metadata;
}
Expand description

An invasively reference counted type.

Objects implementing this trait are always allocated on the heap, and have their lifecycle managed using the RefPtr smart pointer.

§Safety

  • Refcounted objects are always heap-allocated
  • Only shared references may exist to Refcounted objects

Required Associated Types§

Source

type Rc: Refcount

Reference count used by this type.

Required Methods§

Source

unsafe fn refcount_metadata(&self) -> <Self::Rc as Refcount>::Metadata

Metadata used internally by Refcount implementations.

This metadata can be used to implement dynamic extensions to the refcount type, such as finalize support or RTTI.

Implementors§