flex_alloc::alloc

Struct Global

Source
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

Source§

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)

Release an allocation produced by this allocator. Read more
Source§

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>

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>

Try to extend the size of an allocation to accomodate a new, larger layout. Fill the extra capacity with zeros.
Source§

unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>

Try to reduce the size of an allocation to accomodate a new, smaller layout.
Source§

fn by_ref(&self) -> &Self
where Self: Sized,

Obtain a reference to this allocator type.
Source§

impl AllocatorDefault for Global

Source§

const DEFAULT: Self = Global

The constant initializer for this allocator.
Source§

impl Clone for Global

Source§

fn clone(&self) -> Global

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Global

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Global

Source§

fn default() -> Global

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Global

Source§

fn eq(&self, other: &Global) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Global

Source§

impl Eq for Global

Source§

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 A
where A: Allocator,

Source§

type Alloc = A

The type of the allocator instance
Source§

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 instance
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, A> ToOwnedIn<A> for T
where T: Clone + 'static, A: Allocator,

Source§

type Owned = T

The owned representation of this type.
Source§

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::Owned
where I: AllocateIn<Alloc = A>,

Create an owned copy of this instance in a given allocation target.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<A> VecConfig for A
where A: Allocator,

Source§

type Buffer<T> = FatBuffer<T, VecHeader, A>

The internal buffer type.
Source§

type Grow = GrowDoubling

The growth strategy.
Source§

type Index = usize

The index type used to define the capacity and length.
Source§

impl<T, A> VecConfigAlloc<T> for A
where A: Allocator,

Source§

type Alloc = A

The allocator instance type.
Source§

fn allocator( buf: &<A as VecConfig>::Buffer<T>, ) -> &<A as VecConfigAlloc<T>>::Alloc

Get a reference to the allocator instance.
Source§

fn buffer_from_parts( data: NonNull<T>, length: <A as VecConfig>::Index, capacity: <A as VecConfig>::Index, alloc: <A as VecConfigAlloc<T>>::Alloc, ) -> <A as VecConfig>::Buffer<T>

Create a Vec buffer instance from its constituent parts.
Source§

fn buffer_into_parts( buffer: <A as VecConfig>::Buffer<T>, ) -> (NonNull<T>, <A as VecConfig>::Index, <A as VecConfig>::Index, <A as VecConfigAlloc<T>>::Alloc)

Disassemble a Vec buffer instance into its constituent parts.
Source§

impl<T, A> VecConfigNew<T> for A

Source§

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>

Try to create a new buffer instance with a given capacity.
Source§

impl<T, A> VecConfigSpawn<T> for A
where A: Allocator + Clone,

Source§

fn buffer_try_spawn( buf: &<A as VecConfig>::Buffer<T>, 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, C> VecNewIn<T> for C
where C: AllocateIn,

Source§

type Config = <C as AllocateIn>::Alloc

The associated Vec configuration type.
Source§

fn buffer_try_new_in( self, capacity: <<C as VecNewIn<T>>::Config as VecConfig>::Index, exact: bool, ) -> Result<<<C as VecNewIn<T>>::Config as VecConfig>::Buffer<T>, StorageError>

Try to create a new buffer given an allocation target.