pub struct GrowablePool { /* fields omitted */ }A pool of Growable objects. Unlike a typical Arena-based allocator it probably
will not be able to decrease a memory fragmentation or provide some strong
guarantees about frequency of allocations in your code but instead
can be used to reduce the total amount of allocations in an amortized way
by reusing the same memory to store different objects.
Let's start off by creating a default GrowablePool.
let mut pool = GrowablePool::default();
We can now use it to allocate some data and do something with it.
let arr: Reusable<[u8]> = pool.allocate([1, 2, 3, 4, 5, 6]);
assert_eq!(&*arr, &[1, 2, 3, 4, 5, 6]);
An then return it back to the pool..
.. and reuse the same heap to store something else.
let arr: Reusable<[u8]> = pool.allocate([1, 2, 3]);
assert_eq!(&*arr, &[1, 2, 3]);
Creates a new pool builder with default options.
Returns true if a reallocation will be needed to allocate an another one object.
Returns the current amount of allocations that this pool can provide without a reallocation.
Allocates a new Reusable from the pool.
If no Growable is available for allocation, the entire pool will be reallocated.
Returns the Reusable back to the pool, marking it
available for a next allocation.
With overgrow disabled the Growable might be dropped entirely if
there is not enough free space available in the pool.
Returns the "default value" for a type. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Mutably borrows from an owned value. Read more