Trait composable_allocators::Composable
source · [−]pub unsafe trait Composable: Allocator {
unsafe fn has_allocated(&self, ptr: NonNull<u8>, layout: Layout) -> bool;
fn manages_on_its_own(&self, layout: Layout) -> bool;
}
Expand description
Safety
The manages_on_its_own
function should be pure, i.e. always return same value
for same layout
.
An implementer of this trait should return true
from
has_allocated
if and only if at least one of the following conditions is satisfied:
-
the passed pointer is denoting to currently allocated block,
-
manages_on_its_own
returns true forLayout
used to allocate memory block, denoting byptr
.
Required Methods
Safety
The ptr
parameter should denote a memory block,
currently allocated
by this or any other Allocator
.
The layout
parameter should
fit
the memory block denoting by ptr
.