pub unsafe trait Fallbackable: Allocator {
// Required methods
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_fallback
returns false forLayout
used to allocate memory block, denoting byptr
.
Required Methods§
Sourceunsafe fn has_allocated(&self, ptr: NonNull<u8>, layout: Layout) -> bool
unsafe fn has_allocated(&self, ptr: NonNull<u8>, layout: Layout) -> bool
§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
.