# [−][src]Struct std::alloc::Global

    pub struct Global;

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

The global memory allocator.

This type implements the `AllocRef` 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 AllocRef for Global`[src]

#### `fn alloc(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr>`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Attempts to allocate a block of memory. Read more

#### `fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr>`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Behaves like `alloc`, but also ensures that the returned memory is zero-initialized. Read more

#### `unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout)`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Deallocates the memory referenced by `ptr`. Read more

#### `unsafe fn grow(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<NonNull<[u8]>, AllocErr>`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Attempts to extend the memory block. Read more

#### `unsafe fn grow_zeroed(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<NonNull<[u8]>, AllocErr>`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Behaves like `grow`, but also ensures that the new contents are set to zero before being returned. Read more

#### `unsafe fn shrink(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<NonNull<[u8]>, AllocErr>`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Attempts to shrink the memory block. Read more

#### `fn by_ref(&mut self) -> &mut Selfⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized, '_> Read for &'_ mut Rimpl<W: Write + ?Sized, '_> Write for &'_ mut W`
`[src]

🔬 This is a nightly-only experimental API. (`allocator_api` #32838)

Creates a "by reference" adaptor for this instance of `AllocRef`. Read more

### `impl Clone for Global`[src]

#### `fn clone(&self) -> Global`[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl Copy for Global`[src]

### `impl Debug for Global`[src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>`[src]

Formats the value using the given formatter. Read more

### `impl Default for Global`[src]

#### `fn default() -> Global`[src]

Returns the "default value" for a type. Read more

## 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> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `fn borrow(&self) -> &Tⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized, '_> Read for &'_ mut Rimpl<W: Write + ?Sized, '_> Write for &'_ mut W`
`[src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `fn borrow_mut(&mut self) -> &mut Tⓘ

### Notable traits for &'_ mut F

`impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<R: Read + ?Sized, '_> Read for &'_ mut Rimpl<W: Write + ?Sized, '_> Write for &'_ mut W`
`[src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `fn to_owned(&self) -> T`[src]

Creates owned data from borrowed data, usually by cloning. Read more

#### `fn clone_into(&self, target: &mut T)`[src]

🔬 This is a nightly-only experimental API. (`toowned_clone_into` #41263)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.