pub struct Global;
Expand description
The global memory allocator.
When the alloc
feature is enabled, this type implements the Allocator
trait by forwarding calls to the allocator registered with the
#[global_allocator]
attribute if there is one, or the std
crate’s default.
Trait Implementations§
Source§impl Allocator for Global
impl Allocator for Global
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Try to allocate a slice of memory within this allocator instance,
returning the new allocation.
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
Release an allocation produced by this allocator. Read more
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Try to allocate a slice of memory within this allocator instance,
returning the new allocation. The memory will be initialized with zeroes.
Source§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>
Try to extend the size of an allocation to accomodate a new, larger layout.
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>
Try to extend the size of an allocation to accomodate a new, larger layout.
Fill the extra capacity with zeros.
Source§impl AllocatorDefault for Global
impl AllocatorDefault for Global
impl Copy for Global
impl Eq for Global
impl StructuralPartialEq for Global
Auto Trait Implementations§
impl Freeze for Global
impl RefUnwindSafe for Global
impl Send for Global
impl Sync for Global
impl Unpin for Global
impl UnwindSafe for Global
Blanket Implementations§
Source§impl<A> AllocateIn for Awhere
A: Allocator,
impl<A> AllocateIn for Awhere
A: Allocator,
Source§fn allocate_in(
self,
layout: Layout,
) -> Result<(NonNull<[u8]>, <A as AllocateIn>::Alloc), AllocError>
fn allocate_in( self, layout: Layout, ) -> Result<(NonNull<[u8]>, <A as AllocateIn>::Alloc), AllocError>
Try to allocate a slice of a memory corresponding to
layout
, returning
the new allocation and the allocator instanceSource§fn allocate_zeroed_in(
self,
layout: Layout,
) -> Result<(NonNull<[u8]>, <A as AllocateIn>::Alloc), AllocError>
fn allocate_zeroed_in( self, layout: Layout, ) -> Result<(NonNull<[u8]>, <A as AllocateIn>::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.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T, A> ToOwnedIn<A> for T
impl<T, A> ToOwnedIn<A> for T
Source§fn try_to_owned_in<I>(
&self,
_alloc_in: I,
) -> Result<<T as ToOwnedIn<A>>::Owned, StorageError>where
I: AllocateIn<Alloc = A>,
fn try_to_owned_in<I>(
&self,
_alloc_in: I,
) -> Result<<T as ToOwnedIn<A>>::Owned, StorageError>where
I: AllocateIn<Alloc = A>,
To to create an owned copy of this instance in a given allocation target.
Source§fn to_owned_in<I>(&self, alloc_in: I) -> Self::Ownedwhere
I: AllocateIn<Alloc = A>,
fn to_owned_in<I>(&self, alloc_in: I) -> Self::Ownedwhere
I: AllocateIn<Alloc = A>,
Create an owned copy of this instance in a given allocation target.
Source§impl<T, A> VecConfigAlloc<T> for Awhere
A: Allocator,
impl<T, A> VecConfigAlloc<T> for Awhere
A: Allocator,
Source§fn allocator(
buf: &<A as VecConfig>::Buffer<T>,
) -> &<A as VecConfigAlloc<T>>::Alloc
fn allocator( buf: &<A as VecConfig>::Buffer<T>, ) -> &<A as VecConfigAlloc<T>>::Alloc
Get a reference to the allocator instance.
Source§impl<T, A> VecConfigNew<T> for Awhere
A: AllocatorDefault,
impl<T, A> VecConfigNew<T> for Awhere
A: AllocatorDefault,
Source§const EMPTY_BUFFER: <A as VecConfig>::Buffer<T> = const EMPTY_BUFFER: Self::Buffer<T> =
FatBuffer<T, VecHeader<usize>, A>::DEFAULT;
const EMPTY_BUFFER: <A as VecConfig>::Buffer<T> = const EMPTY_BUFFER: Self::Buffer<T> = FatBuffer<T, VecHeader<usize>, A>::DEFAULT;
Constant initializer for an empty buffer.
Source§fn buffer_try_new(
capacity: <A as VecConfig>::Index,
exact: bool,
) -> Result<<A as VecConfig>::Buffer<T>, StorageError>
fn buffer_try_new( capacity: <A as VecConfig>::Index, exact: bool, ) -> Result<<A as VecConfig>::Buffer<T>, StorageError>
Try to create a new buffer instance with a given capacity.
Source§impl<T, A> VecConfigSpawn<T> for A
impl<T, A> VecConfigSpawn<T> for A
Source§impl<T, C> VecNewIn<T> for Cwhere
C: AllocateIn,
impl<T, C> VecNewIn<T> for Cwhere
C: AllocateIn,
Source§type Config = <C as AllocateIn>::Alloc
type Config = <C as AllocateIn>::Alloc
The associated
Vec
configuration type.