pub struct Arena { /* private fields */ }
Expand description
A bump allocation arena.
let mut arena = Arena::new(1000);
let mut buffers = Vec::new();
for _ in 0..10 {
let mut buf = arena.alloc(100);
buffers.push(buf);
}
drop(arena);
buffers[0][0] = 1;
Creates a new Arena
using the given chunk_size
for every allocated chunk.
Panics if chunk_size
is bigger than isize::MAX
.
Allocates a new BytesMut
from the Arena
.
Note that the returned BytesMut
may contain previously used buffers. If you need to
create a zeroed BytesMut
, consider using zeroed
.
Allocates a new, zeroed BytesMut
from the Arena
.
Note that zeroed
zeroes the returned BytesMut
. If that’s not necessary you may want
to use alloc
, which does not zero the returned BytesMut
.
Formats the value using the given formatter.
Read more
Returns the “default value” for a type.
Read more
Executes the destructor for this type.
Read more
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.