Trait Allocator

Source
pub unsafe trait Allocator {
    // Required methods
    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
    unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout);

    // Provided methods
    fn allocate_zeroed(
        &self,
        layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> { ... }
    unsafe fn grow(
        &self,
        ptr: NonNull<u8>,
        old_layout: Layout,
        new_layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> { ... }
    unsafe fn grow_zeroed(
        &self,
        ptr: NonNull<u8>,
        old_layout: Layout,
        new_layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> { ... }
    unsafe fn shrink(
        &self,
        ptr: NonNull<u8>,
        old_layout: Layout,
        new_layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError> { ... }
    fn by_ref(&self) -> &Self
       where Self: Sized { ... }
}
Expand description

A fallback for alloc::alloc::Allocator, which is currently unstable.

§Safety

See alloc::alloc::Allocator.

Required Methods§

Provided Methods§

Implementations on Foreign Types§

Source§

impl<A> Allocator for &A
where A: Allocator + ?Sized,

Source§

fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>

Source§

unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)

Implementors§