Struct std::alloc::Global
pub struct Global;
The global memory allocator.
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.
Note: while this type is unstable, the functionality it provides can be accessed through the free functions in alloc
.
Trait Implementations
impl Allocator for Global
pub fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Attempts to allocate a block of memory. Read more
pub fn allocate_zeroed(
&self,
layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
Behaves like allocate
, but also ensures that the returned memory is zero-initialized. Read more
pub unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
Deallocates the memory referenced by ptr
. Read more
pub unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
Attempts to extend the memory block. Read more
pub unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
Behaves like grow
, but also ensures that the new contents are set to zero before being returned. Read more
pub unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
Attempts to shrink the memory block. Read more
fn by_ref(&self) -> &Self
Creates a “by reference” adapter for this instance of Allocator
. Read more
impl Clone for Global
pub fn clone(&self) -> Global
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Global
pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl Default for Global
impl Copy for Global
Auto Trait Implementations
impl RefUnwindSafe for Global
impl Send for Global
impl Sync for Global
impl Unpin for Global
impl UnwindSafe for Global
Blanket Implementations
impl<T> From<T> for T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
Performs the conversion.
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
#41263)recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
Performs the conversion.
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
Performs the conversion.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/alloc/struct.Global.html