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§
Sourcefn used_bytes(&self) -> usize
fn used_bytes(&self) -> usize
Returns the number of bytes currently in use.
Sourcefn alloc_as_slice<T>(&self, value: T) -> &mut [T]
fn alloc_as_slice<T>(&self, value: T) -> &mut [T]
Allocates a value as a slice of length 1.
Sourcefn alloc_from_iter<T>(&self, iter: impl Iterator<Item = T>) -> &mut [T]
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.
Sourcefn alloc_vec<T>(&self, values: Vec<T>) -> &mut [T]
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.
Sourcefn alloc_smallvec<A: Array>(&self, values: SmallVec<A>) -> &mut [A::Item]
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.
Sourcefn alloc_array<T, const N: usize>(&self, values: [T; N]) -> &mut [T]
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.
Sourceunsafe fn alloc_slice_unchecked<'a, T>(&'a self, slice: &[T]) -> &'a mut [T]
unsafe fn alloc_slice_unchecked<'a, T>(&'a self, slice: &[T]) -> &'a mut [T]
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.