Skip to main content

CompactArcDrop

Trait CompactArcDrop 

Source
pub unsafe trait CompactArcDrop {
    // Required method
    unsafe fn drop_and_dealloc(ptr: *mut u8);
}
Expand description

Trait for type-specific drop and deallocation logic.

This trait enables compile-time dispatch for dropping CompactArc contents, replacing the previous runtime function pointer approach. Since Rust monomorphizes generics, the compiler resolves the correct implementation at compile time - making this both smaller (no stored pointer) and faster (direct call instead of indirect).

§Safety

Implementations must correctly drop T’s data and deallocate the header+data allocation using the correct Layout. This trait is auto-implemented for all types used with CompactArc.

Required Methods§

Source

unsafe fn drop_and_dealloc(ptr: *mut u8)

Drop the contained data and deallocate the header+data allocation.

§Safety

ptr must point to a valid, exclusively-owned CompactArc allocation (starting at the Header) that was created by CompactArc’s constructors.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CompactArcDrop for str

Source§

impl<T> CompactArcDrop for [T]

Implementors§