BumpExt

Trait BumpExt 

Source
pub trait BumpExt {
    // Required methods
    fn used_bytes(&self) -> usize;
    fn alloc_as_slice<T>(&self, value: T) -> &mut [T];
    fn alloc_from_iter<T>(&self, iter: impl Iterator<Item = T>) -> &mut [T];
    fn alloc_vec<T>(&self, values: Vec<T>) -> &mut [T];
    fn alloc_smallvec<A: Array>(&self, values: SmallVec<A>) -> &mut [A::Item];
    fn alloc_array<T, const N: usize>(&self, values: [T; N]) -> &mut [T];
    unsafe fn alloc_slice_unchecked<'a, T>(&'a self, slice: &[T]) -> &'a mut [T];
}
Expand description

Extension trait for Bump.

Required Methods§

Source

fn used_bytes(&self) -> usize

Returns the number of bytes currently in use.

Source

fn alloc_as_slice<T>(&self, value: T) -> &mut [T]

Allocates a value as a slice of length 1.

Source

fn alloc_from_iter<T>(&self, iter: impl Iterator<Item = T>) -> &mut [T]

Allocates an iterator by first collecting it into a (possibly stack-allocated) vector.

Does not collect if the iterator is exact size, meaning size_hint returns equal values.

Source

fn alloc_vec<T>(&self, values: Vec<T>) -> &mut [T]

Allocates a vector of items on the arena.

NOTE: This method does not drop the values, so you likely want to wrap the result in a [bumpalo::boxed::Box] if T: Drop.

Source

fn alloc_smallvec<A: Array>(&self, values: SmallVec<A>) -> &mut [A::Item]

Allocates a SmallVector of items on the arena.

NOTE: This method does not drop the values, so you likely want to wrap the result in a [bumpalo::boxed::Box] if T: Drop.

Source

fn alloc_array<T, const N: usize>(&self, values: [T; N]) -> &mut [T]

Allocates an array of items on the arena.

NOTE: This method does not drop the values, so you likely want to wrap the result in a [bumpalo::boxed::Box] if T: Drop.

Source

unsafe fn alloc_slice_unchecked<'a, T>(&'a self, slice: &[T]) -> &'a mut [T]

Allocates a slice of items on the arena and copies them in.

§Safety

If T: Drop, the resulting slice must not be wrapped in [bumpalo::boxed::Box], unless ownership is moved as well, such as through alloc_vec and the other methods in this trait.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl BumpExt for Bump

Source§

fn used_bytes(&self) -> usize

Source§

fn alloc_as_slice<T>(&self, value: T) -> &mut [T]

Source§

fn alloc_from_iter<T>(&self, iter: impl Iterator<Item = T>) -> &mut [T]

Source§

fn alloc_vec<T>(&self, values: Vec<T>) -> &mut [T]

Source§

fn alloc_smallvec<A: Array>(&self, values: SmallVec<A>) -> &mut [A::Item]

Source§

fn alloc_array<T, const N: usize>(&self, values: [T; N]) -> &mut [T]

Source§

unsafe fn alloc_slice_unchecked<'a, T>(&'a self, src: &[T]) -> &'a mut [T]

Implementors§