Trait composable_allocators::Fallbackable
source · [−]pub unsafe trait Fallbackable: Allocator {
unsafe fn has_allocated(&self, ptr: NonNull<u8>, layout: Layout) -> bool;
fn allows_fallback(&self, layout: Layout) -> bool;
}Expand description
Safety
The allows_fallback 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,
-
allows_fallbackreturns false forLayoutused 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.