This crate provides [BlindPool], a dynamically growing pool of objects that can store
objects of any type.
It offers stable memory addresses and efficient typed insertion with automatic value dropping.
Type-agnostic memory management
The pool itself does not hold or create any & shared or &mut exclusive references to its
contents, allowing the caller to decide who and when can obtain a reference to the inserted
values. The caller is responsible for ensuring that Rust aliasing rules are respected.
Features
- Type-agnostic memory management: Accepts any type.
- Stable addresses: Memory addresses remain valid until explicitly removed.
- Automatic dropping: Values are properly dropped when removed from the pool.
- Dynamic growth: Pool capacity grows automatically as needed.
- Efficient allocation: Uses high density slabs to minimize allocation overhead.
- Stable Rust: No unstable Rust features required.
- Optional leak detection: Pool can be configured to panic on drop if values are still present.
Example
use BlindPool;
// Create a blind pool that can store any type.
let mut pool = new;
// Insert values of different types into the same pool.
let pooled_u64 = pool.insert;
let pooled_i32 = pool.insert;
let pooled_f32 = pool.insert;
// Read data back from the pooled items.
let value_u64 = unsafe ;
let value_i32 = unsafe ;
assert_eq!;
assert_eq!;