Struct Array

Source
pub struct Array<const N: usize> { /* private fields */ }
Expand description

An allocator that hands out allocations from a statically-sized chunk of bytes.

If the memory is exhausted, the only way to obtain more is to free all existing allocations. Alternatively, you can layer another allocator on top of this one that uses a more sophisticated allocation strategy.

Implementations§

Source§

impl<const N: usize> Array<N>

Source

pub fn new() -> Self

Create a new, empty array allocator.

Note that the internal buffer is uninitialized. This does not matter, since memory allocated via the Allocator interface has no guarantees about initialization.

Trait Implementations§

Source§

impl<const N: usize> Allocator for Array<N>

Source§

fn brand(&self) -> &Brand

The unique brand of this allocator, that prevents allocations from other allocators from being freed in this one, and vice-versa.
Source§

fn alloc_bytes(&self, layout: Layout) -> Result<Alloc<'_, u8>, Error>

Create an allocation of a certain layout, treating it as bytes. Read more
Source§

fn dealloc_bytes<'this>(&'this self, alloc: Alloc<'this, u8>)

Free an allocation. Read more
Source§

fn dangling(&self, align: Align) -> Alloc<'_, u8>

Returns a zero-sized allocation. Read more
Source§

fn total_size(&self) -> Option<usize>

The total size available to be allocated. Read more
Source§

fn remaining_size(&self) -> Option<usize>

The remaining amount of memory available to be allocated. Read more
Source§

fn alloc_zeroed(&self, layout: Layout) -> Result<Alloc<'_, u8>, Error>

Like alloc_bytes, but guarantees that it is filled with zeroes. Read more
Source§

fn realloc<'this>( &'this self, alloc: Alloc<'this, u8>, layout: Layout, ) -> Result<Alloc<'this, u8>, Error>

Transform a given allocation to a new layout (generally to grow/shrink it). Read more
Source§

fn grow<'this>( &'this self, alloc: Alloc<'this, u8>, layout: Layout, ) -> Result<Alloc<'this, u8>, Error>

Transform a given allocation to a new layout (generally to grow it). Copies previous data into the first bytes of the new allocation, with the remaining bytes uninitialized. Read more
Source§

fn shrink<'this>( &'this self, alloc: Alloc<'this, u8>, layout: Layout, ) -> Result<Alloc<'this, u8>, Error>

Transform a given allocation to a new layout (generally to shrink it). Copies over as much data from the original allocation as will fit. Read more
Source§

impl<const N: usize> Default for Array<N>

Source§

fn default() -> Self

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

impl<const N: usize> Sync for Array<N>

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for Array<N>

§

impl<const N: usize> !RefUnwindSafe for Array<N>

§

impl<const N: usize> Send for Array<N>

§

impl<const N: usize> Unpin for Array<N>

§

impl<const N: usize> UnwindSafe for Array<N>

Blanket Implementations§

Source§

impl<A> AllocatorExt for A
where A: Allocator + ?Sized,

Source§

fn alloc<T>(&self) -> Result<Alloc<'_, T>, Error>

Creates an allocation suitable for a given type T. Read more
Source§

fn dealloc<'this, T>(&'this self, alloc: Alloc<'this, T>)

Free an allocation. Read more
Source§

fn alloc_with<T>(&self, data: T) -> Result<Alloc<'_, T>, (T, Error)>

Creates an allocation suitable for a given type T, and populates it with a given value. If allocation fails, returns the value along with the error value.
Source§

fn as_dyn(&self) -> &dyn Allocator
where Self: Sized,

A convenience method for coercing this to a trait object.
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> 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, 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.