BumpExt

Trait BumpExt 

Source
pub trait BumpExt {
Show 14 methods // 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]; fn alloc_as_thin_slice<H, T>( &self, header: H, value: T, ) -> &mut RawThinSlice<H, T>; fn alloc_from_iter_thin<H, T>( &self, header: H, iter: impl Iterator<Item = T>, ) -> &mut RawThinSlice<H, T>; fn alloc_vec_thin<H, T>( &self, header: H, values: Vec<T>, ) -> &mut RawThinSlice<H, T>; fn alloc_smallvec_thin<H, A: Array>( &self, header: H, values: SmallVec<A>, ) -> &mut RawThinSlice<H, A::Item>; fn alloc_array_thin<H, T, const N: usize>( &self, header: H, values: [T; N], ) -> &mut RawThinSlice<H, T>; unsafe fn alloc_thin_slice_unchecked<'a, H, T>( &'a self, header: H, src: &[T], ) -> &'a mut RawThinSlice<H, T>; // Provided method fn alloc_thin_slice_copy<'a, H, T: Copy>( &'a self, header: H, src: &[T], ) -> &'a mut RawThinSlice<H, 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.

Source

fn alloc_as_thin_slice<H, T>( &self, header: H, value: T, ) -> &mut RawThinSlice<H, T>

Source

fn alloc_from_iter_thin<H, T>( &self, header: H, iter: impl Iterator<Item = T>, ) -> &mut RawThinSlice<H, T>

Source

fn alloc_vec_thin<H, T>( &self, header: H, values: Vec<T>, ) -> &mut RawThinSlice<H, T>

See alloc_vec.

Source

fn alloc_smallvec_thin<H, A: Array>( &self, header: H, values: SmallVec<A>, ) -> &mut RawThinSlice<H, A::Item>

Source

fn alloc_array_thin<H, T, const N: usize>( &self, header: H, values: [T; N], ) -> &mut RawThinSlice<H, T>

Source

unsafe fn alloc_thin_slice_unchecked<'a, H, T>( &'a self, header: H, src: &[T], ) -> &'a mut RawThinSlice<H, T>

Provided Methods§

Source

fn alloc_thin_slice_copy<'a, H, T: Copy>( &'a self, header: H, src: &[T], ) -> &'a mut RawThinSlice<H, 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.

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]

Source§

fn alloc_as_thin_slice<H, T>( &self, header: H, value: T, ) -> &mut RawThinSlice<H, T>

Source§

fn alloc_from_iter_thin<H, T>( &self, header: H, iter: impl Iterator<Item = T>, ) -> &mut RawThinSlice<H, T>

Source§

fn alloc_vec_thin<H, T>( &self, header: H, values: Vec<T>, ) -> &mut RawThinSlice<H, T>

Source§

fn alloc_smallvec_thin<H, A: Array>( &self, header: H, values: SmallVec<A>, ) -> &mut RawThinSlice<H, A::Item>

Source§

fn alloc_array_thin<H, T, const N: usize>( &self, header: H, values: [T; N], ) -> &mut RawThinSlice<H, T>

Source§

unsafe fn alloc_thin_slice_unchecked<'a, H, T>( &'a self, header: H, src: &[T], ) -> &'a mut RawThinSlice<H, T>

Implementors§