Skip to main content

with_capacity

Function with_capacity 

Source
pub fn with_capacity<T>(capacity: usize) -> PoolVec<T>
Expand description

Get a vec from the pool with at least capacity elements of space.

If the pool has a buffer with sufficient capacity, it is reused. Otherwise a fresh Vec::with_capacity(capacity) is allocated.

If the pool has a buffer but its capacity is less than requested, the buffer remains in the pool and a fresh allocation is made.

ยงExample

use vecpool::with_capacity;

let v = with_capacity::<u64>(1000);
assert!(v.capacity() >= 1000);