pub unsafe trait HeapElement {
// Required method
unsafe fn release_elem(ptr: *const Self);
}Expand description
v2-raw HeapHeader-equipped element carrier trait.
Implementors are #[repr(C)] structs with HeapHeader at offset 0. The
trait dispatches per-T release at compile time via the Rust type system;
TypedArray<*const T: HeapElement>::drop_array_heap calls
T::release_elem(elem_ptr) for each stored element.
§Safety
Implementors must guarantee:
Selfis#[repr(C)]with aHeapHeaderfield at offset 0.release_elem(ptr)is sound whenptrpoints to a liveSelfallocation (one that the implementor’s allocator produced and that has not yet been freed).release_elem(ptr)decrements the refcount viav2_releaseand, ifv2_releasereturns true, fully deallocates the allocation (including any nested payload buffers per the implementor’s drop semantics).
Required Methods§
Sourceunsafe fn release_elem(ptr: *const Self)
unsafe fn release_elem(ptr: *const Self)
Decrement the reference count of *ptr. If the refcount reaches
zero, fully deallocate the object (including any nested payload
buffers per the implementor’s drop semantics).
§Safety
ptr must point to a valid, live Self allocated via the
implementor’s canonical v2-raw allocator. After this call returns,
ptr must not be dereferenced (the allocation may have been freed).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".