Skip to main content

DroplessArena

Struct DroplessArena 

pub struct DroplessArena<'arena> {
    _lives: PhantomData<&'arena u8>,
    chunks: RefCell<Vec<ArenaChunk<u8>>>,
    head: Cell<*mut u8>,
    tail: Cell<*mut u8>,
}

Fields§

§_lives: PhantomData<&'arena u8>§chunks: RefCell<Vec<ArenaChunk<u8>>>§head: Cell<*mut u8>§tail: Cell<*mut u8>

Implementations§

§

impl<'arena> DroplessArena<'arena>

pub const fn new() -> DroplessArena<'arena>

pub fn alloc<T>(&'arena self, value: T) -> &'arena mut T

Allocates a T in the DroplessArena, and returns a mutable reference to it.

§Panics
  • Panics if T implements Drop
  • Panics if T is zero-sized

pub fn alloc_slice<T>(&'arena self, slice: &[T]) -> &'arena mut [T]
where T: Copy,

Allocates a slice of Ts`, copied from the given slice, returning a mutable reference to it.

§Panics
  • Panics if T implements Drop
  • Panics if T is zero-sized
  • Panics if the slice is empty

pub fn alloc_str(&'arena self, string: &str) -> &'arena str

Allocates a copy of the given &str, returning a reference to the allocation.

§Panics

Panics if the string is empty.

pub fn alloc_raw(&'arena self, layout: Layout) -> *mut u8

Allocates some bytes based on the given Layout.

§Panics

Panics if the provided Layout has size 0

pub fn contains_slice<T>(&self, slice: &[T]) -> bool

Checks whether the given slice is allocated in this arena

Trait Implementations§

§

impl Default for DroplessArena<'_>

§

fn default() -> DroplessArena<'_>

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

impl Send for DroplessArena<'_>

Auto Trait Implementations§

§

impl<'arena> !Freeze for DroplessArena<'arena>

§

impl<'arena> !RefUnwindSafe for DroplessArena<'arena>

§

impl<'arena> !Sync for DroplessArena<'arena>

§

impl<'arena> Unpin for DroplessArena<'arena>

§

impl<'arena> UnwindSafe for DroplessArena<'arena>

Blanket Implementations§

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.