Trait AllocateIn

Source
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§

Source

type Alloc: Allocator

The type of the allocator instance

Required Methods§

Source

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§

Source

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.

Implementors§

Source§

impl<'a, I, A> AllocateIn for SpillStorage<'a, I, A>
where I: AllocateIn<Alloc = Fixed<'a>>, A: Allocator,

Source§

type Alloc = Spill<'a, A>

Source§

impl<'a, T, const N: usize> AllocateIn for &'a mut ByteStorage<T, N>

Source§

type Alloc = Fixed<'a>

Source§

impl<A: Allocator> AllocateIn for A

Source§

type Alloc = A