pub struct DefaultAlloc;Expand description
Default allocator, delegating to the global allocator.
§Note
This must not be set as the global allocator (via #[global_allocator]). Doing so will lead
to infinite recursion, as the allocation functions this calls (in alloc::alloc) delegate to
the global allocator.
Trait Implementations§
Source§impl Alloc for DefaultAlloc
Available on non-crate feature no_alloc only.
impl Alloc for DefaultAlloc
Available on non-crate feature
no_alloc only.Source§impl Allocator for DefaultAlloc
impl Allocator for DefaultAlloc
Source§fn allocate(&self, layout: StdLayout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: StdLayout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api)Attempts to allocate a block of memory. Read more
Source§fn allocate_zeroed(
&self,
layout: StdLayout,
) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed( &self, layout: StdLayout, ) -> 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 deallocate(&self, ptr: NonNull<u8>, layout: StdLayout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: StdLayout)
🔬This is a nightly-only experimental API. (
allocator_api)Deallocates the memory referenced by
ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: StdLayout,
new_layout: StdLayout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: StdLayout, new_layout: StdLayout, ) -> 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: StdLayout,
new_layout: StdLayout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: StdLayout, new_layout: StdLayout, ) -> 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 moreSource§impl Clone for DefaultAlloc
impl Clone for DefaultAlloc
Source§fn clone(&self) -> DefaultAlloc
fn clone(&self) -> DefaultAlloc
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Dealloc for DefaultAlloc
Available on non-crate feature no_alloc only.
impl Dealloc for DefaultAlloc
Available on non-crate feature
no_alloc only.Source§unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout)
Deallocates a previously allocated block. Read more
Source§unsafe fn try_dealloc(
&self,
ptr: NonNull<u8>,
layout: Layout,
) -> Result<(), Error>
unsafe fn try_dealloc( &self, ptr: NonNull<u8>, layout: Layout, ) -> Result<(), Error>
Attempts to deallocate a previously allocated block. If this allocator is backed by an
allocation library which does not provide fallible deallocation operations, this may panic,
abort, or incorrectly return
Ok(()). Read moreSource§impl Debug for DefaultAlloc
impl Debug for DefaultAlloc
Source§impl Default for DefaultAlloc
impl Default for DefaultAlloc
Source§fn default() -> DefaultAlloc
fn default() -> DefaultAlloc
Returns the “default value” for a type. Read more
Source§impl GlobalAlloc for DefaultAlloc
Available on non-crate feature no_alloc only.
impl GlobalAlloc for DefaultAlloc
Available on non-crate feature
no_alloc only.Source§unsafe fn alloc(&self, layout: StdLayout) -> *mut u8
unsafe fn alloc(&self, layout: StdLayout) -> *mut u8
Allocates memory as described by the given
layout. Read moreSource§impl Grow for DefaultAlloc
Available on non-crate feature no_alloc only.
impl Grow for DefaultAlloc
Available on non-crate feature
no_alloc only.Source§impl Hash for DefaultAlloc
impl Hash for DefaultAlloc
Source§impl Ord for DefaultAlloc
impl Ord for DefaultAlloc
Source§fn cmp(&self, other: &DefaultAlloc) -> Ordering
fn cmp(&self, other: &DefaultAlloc) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for DefaultAlloc
impl PartialEq for DefaultAlloc
Source§impl PartialOrd for DefaultAlloc
impl PartialOrd for DefaultAlloc
Source§impl Realloc for DefaultAlloc
Available on non-crate feature no_alloc only.
impl Realloc for DefaultAlloc
Available on non-crate feature
no_alloc only.Source§impl Shrink for DefaultAlloc
Available on non-crate feature no_alloc only.
impl Shrink for DefaultAlloc
Available on non-crate feature
no_alloc only.impl Copy for DefaultAlloc
impl Eq for DefaultAlloc
impl StructuralPartialEq for DefaultAlloc
Auto Trait Implementations§
impl Freeze for DefaultAlloc
impl RefUnwindSafe for DefaultAlloc
impl Send for DefaultAlloc
impl Sync for DefaultAlloc
impl Unpin for DefaultAlloc
impl UnwindSafe for DefaultAlloc
Blanket Implementations§
Source§impl<A> AllocMut for A
impl<A> AllocMut for A
Source§impl<A> AllocTemp for Awhere
A: BasicAlloc,
impl<A> AllocTemp for Awhere
A: BasicAlloc,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> DeallocMut for A
impl<A> DeallocMut for A
Source§unsafe fn dealloc_mut(&mut self, ptr: NonNull<u8>, layout: Layout)
unsafe fn dealloc_mut(&mut self, ptr: NonNull<u8>, layout: Layout)
Deallocates a previously allocated block. Read more
Source§unsafe fn try_dealloc_mut(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
) -> Result<(), <A as AllocMut>::Error>
unsafe fn try_dealloc_mut( &mut self, ptr: NonNull<u8>, layout: Layout, ) -> Result<(), <A as AllocMut>::Error>
Attempts to deallocate a previously allocated block. If this allocator is backed by an
allocation library which does not provide fallible deallocation operations, this may panic,
abort, or incorrectly return
Ok(()). Read more