pub trait AllocateIn: Sized {
type Alloc: Allocator;
// Required method
fn allocate_in(
self,
layout: Layout,
) -> Result<(NonNull<[u8]>, Self::Alloc), AllocError>;
// Provided method
fn allocate_zeroed_in(
self,
layout: Layout,
) -> Result<(NonNull<[u8]>, Self::Alloc), AllocError> { ... }
}
Expand description
For all types which are an allocator or reference an allocator, enable their usage as a target for allocation.
Required Associated Types§
Required Methods§
Sourcefn allocate_in(
self,
layout: Layout,
) -> Result<(NonNull<[u8]>, Self::Alloc), AllocError>
fn allocate_in( self, layout: Layout, ) -> Result<(NonNull<[u8]>, Self::Alloc), AllocError>
Try to allocate a slice of a memory corresponding to layout
, returning
the new allocation and the allocator instance
Provided Methods§
Sourcefn allocate_zeroed_in(
self,
layout: Layout,
) -> Result<(NonNull<[u8]>, Self::Alloc), AllocError>
fn allocate_zeroed_in( self, layout: Layout, ) -> Result<(NonNull<[u8]>, Self::Alloc), AllocError>
Try to allocate a slice of a memory corresponding to layout
, returning
the new allocation and the allocator instance. The memory will be initialized
with zeroes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.