pub struct SingleAllocation<'a> { /* private fields */ }Expand description
Allocator which will allocate only once at a time.
Implementations§
Source§impl SingleAllocation<'_>
impl SingleAllocation<'_>
Sourcepub fn new<T>(data: &mut [MaybeUninit<T>]) -> Self
pub fn new<T>(data: &mut [MaybeUninit<T>]) -> Self
Construct a new [OnceAllocator], which will use the data as its underlying memory.
Trait Implementations§
Source§impl Allocator for SingleAllocation<'_>
impl Allocator for SingleAllocation<'_>
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api)Attempts to allocate a block of memory. Read more
Source§unsafe fn deallocate(&self, _: NonNull<u8>, _: Layout)
unsafe fn deallocate(&self, _: NonNull<u8>, _: Layout)
🔬This is a nightly-only experimental API. (
allocator_api)Deallocates the memory referenced by
ptr. Read moreSource§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api)Behaves like
allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api)Attempts to extend the memory block. Read more
Source§unsafe fn grow_zeroed(
&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>
🔬This is a nightly-only experimental API. (
allocator_api)Behaves like
grow, but also ensures that the new contents are set to zero before being
returned. Read moreAuto Trait Implementations§
impl<'a> !Freeze for SingleAllocation<'a>
impl<'a> !Send for SingleAllocation<'a>
impl<'a> !Sync for SingleAllocation<'a>
impl<'a> RefUnwindSafe for SingleAllocation<'a>
impl<'a> Unpin for SingleAllocation<'a>
impl<'a> UnsafeUnpin for SingleAllocation<'a>
impl<'a> UnwindSafe for SingleAllocation<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more