Skip to main content

Alloc

Trait Alloc 

Source
pub trait Alloc: AllocErrorType + AllocMut {
    // Required method
    fn alloc(
        &self,
        layout: Layout,
    ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>;

    // Provided method
    fn zalloc(
        &self,
        layout: Layout,
    ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error> { ... }
}
Expand description

A memory allocation interface.

Required Methods§

Source

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Attempts to allocate a block of memory fitting the given Layout.

§Errors

Errors are implementation-defined, refer to AllocErrorType::Error and Error.

The standard implementations may return:

Provided Methods§

Source

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Attempts to allocate a zeroed block of memory fitting the given Layout.

§Errors

Errors are implementation-defined, refer to AllocErrorType::Error and Error.

The standard implementations may return:

Implementations on Foreign Types§

Source§

impl Alloc for Global

Available on non-crate feature no_alloc only.
Source§

fn alloc(&self, layout: Layout) -> Result<NonNull<u8>, Error>

Source§

fn zalloc(&self, layout: Layout) -> Result<NonNull<u8>, Error>

Source§

impl Alloc for System

Available on crate feature std and non-crate feature no_alloc only.
Source§

fn alloc(&self, layout: Layout) -> Result<NonNull<u8>, Error>

Source§

fn zalloc(&self, layout: Layout) -> Result<NonNull<u8>, Error>

Source§

impl<A: AllocMut + ?Sized> Alloc for RefCell<A>

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: AllocMut + ?Sized> Alloc for Mutex<A>

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: AllocMut + ?Sized> Alloc for RwLock<A>

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: Alloc + ?Sized> Alloc for &A

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: Alloc + ?Sized> Alloc for &mut A

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: Alloc + ?Sized> Alloc for Box<A>

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: Alloc + ?Sized> Alloc for Rc<A>

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

impl<A: Alloc + ?Sized> Alloc for Arc<A>

Source§

fn alloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Source§

fn zalloc( &self, layout: Layout, ) -> Result<NonNull<u8>, <Self as AllocErrorType>::Error>

Implementors§

Source§

impl Alloc for CAlloc

Source§

impl Alloc for DefaultAlloc

Available on non-crate feature no_alloc only.