pub struct Chain { /* private fields */ }
Expand description
A Chain
is a simple bump allocator, that draws
it’s memory from another allocator. Chain allocators
can be chained together using Chain::chain
.
Implementations§
Source§impl Chain
impl Chain
Sourcepub fn new(size: usize) -> Result<Self, TryNewError>
pub fn new(size: usize) -> Result<Self, TryNewError>
Creates a new Chain
that has a capacity of size
bytes.
Sourcepub fn bump_box<'bump, T: 'bump>(
&'bump self,
) -> Result<LeakBox<'bump, MaybeUninit<T>>, Failure>
pub fn bump_box<'bump, T: 'bump>( &'bump self, ) -> Result<LeakBox<'bump, MaybeUninit<T>>, Failure>
Attempts to allocate elem
within the allocator.
Sourcepub fn chain(&self, new: Chain)
pub fn chain(&self, new: Chain)
Chains self
together with new
.
Following allocations will first be allocated from new
.
Note that this will drop all but the first link from new
.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of this Chain
.
This is how many bytes in total can
be allocated within this Chain
.
Sourcepub fn remaining_capacity(&self) -> usize
pub fn remaining_capacity(&self) -> usize
Returns the remaining capacity of this Chain
.
This is how many more bytes can be allocated
within this Chain
.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Chain
impl !RefUnwindSafe for Chain
impl !Send for Chain
impl !Sync for Chain
impl Unpin for Chain
impl !UnwindSafe for Chain
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