Skip to main content

BumpExt

Trait BumpExt 

Source
pub trait BumpExt {
Show 15 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_smallvec_drain_thin<H, A: Array>( &self, header: H, values: &mut 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.

The arena never runs destructors, so the safe allocation methods reject element types that need drop at compile time, since their owned memory would leak. Use DropArena for such values.

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.

Source

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

Allocates a SmallVector of items on the arena.

Source

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

Allocates an array of items on the arena.

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_smallvec_drain_thin<H, A: Array>( &self, header: H, values: &mut SmallVec<A>, ) -> &mut RawThinSlice<H, A::Item>

Like alloc_smallvec_thin, but moves the elements out of values and leaves it empty, instead of moving values itself, which would copy its inline buffer.

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".

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_smallvec_drain_thin<H, A: Array>( &self, header: H, values: &mut 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§