pub trait Alloc {
// Required method
fn alloc(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>;
// Provided method
fn zalloc(&self, layout: Layout) -> Result<NonNull<u8>, AllocError> { ... }
}Expand description
A memory allocation interface.
Required Methods§
Sourcefn alloc(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
fn alloc(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
Attempts to allocate a block of memory fitting the given Layout.
§Errors
AllocError::AllocFailedif allocation fails.AllocError::ZeroSizedLayoutiflayouthas a size of zero.
Provided Methods§
Sourcefn zalloc(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
fn zalloc(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
Attempts to allocate a zeroed block of memory fitting the given Layout.
§Errors
AllocError::AllocFailedif allocation fails.AllocError::ZeroSizedLayoutiflayouthas a size of zero.