pub struct DroplessArena { /* private fields */ }
Expand description
An arena that can hold objects of multiple different types that impl Copy
and/or satisfy !mem::needs_drop
.
Implementations§
source§impl DroplessArena
impl DroplessArena
sourcepub fn alloc<T>(&self, object: T) -> &mut T
pub fn alloc<T>(&self, object: T) -> &mut T
Allocates an object which doesn’t need to be dropped.
Panics if given a type with drop code. This method’s signature looks like it can allocate any object, but it asserts ![needs_drop] at runtime.
sourcepub fn alloc_from_iter<T, I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T]
pub fn alloc_from_iter<T, I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T]
Allocates an iterator of objects which don’t need to be dropped.
Panics if you try to allocate ZSTs. Additionally, like with Self::alloc, this panics if you allocate an object with drop code.
sourcepub fn alloc_slice<T: Copy>(&self, slice: &[T]) -> &mut [T]
pub fn alloc_slice<T: Copy>(&self, slice: &[T]) -> &mut [T]
Allocates a slice of objects that are copied into the DroplessArena
, returning a mutable
reference to it.
This will panic if passed a zero-sized type or empty slice. Like Self::alloc, it can’t
be given a type with drop code, but the T: Copy
trait checks this at compile time.