pub struct Bump { /* private fields */ }Expand description
Bump-pointer arena.
Implementations§
Source§impl Bump
impl Bump
Sourcepub fn with_capacity(initial_bytes: usize) -> Self
pub fn with_capacity(initial_bytes: usize) -> Self
New arena, pre-allocating the first chunk at initial_bytes bytes.
Sourcepub fn alloc_copy<T: Copy>(&mut self, value: T) -> &mut T
pub fn alloc_copy<T: Copy>(&mut self, value: T) -> &mut T
Allocate a Copy value. Returns an exclusive reference valid until
the next call to reset or arena drop.
Sourcepub fn alloc_raw(&mut self, layout: Layout) -> *mut u8
pub fn alloc_raw(&mut self, layout: Layout) -> *mut u8
Allocate size bytes, aligned to align. Returns a raw pointer; the
caller is responsible for writing into it. Used by alloc_copy.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Rewind to empty without freeing chunks. The next alloc_* call reuses
the same chunks.
Sourcepub fn total_capacity(&self) -> usize
pub fn total_capacity(&self) -> usize
Total bytes currently allocated across all chunks.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Bump
impl !RefUnwindSafe for Bump
impl !Send for Bump
impl !Sync for Bump
impl Unpin for Bump
impl UnsafeUnpin for Bump
impl UnwindSafe for Bump
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more