12 releases
Uses new Rust 2024
| new 0.7.6 | Nov 11, 2025 |
|---|---|
| 0.7.5 | Nov 10, 2025 |
| 0.7.2 | Sep 22, 2025 |
| 0.6.0 | Sep 10, 2025 |
| 0.5.3 | Sep 9, 2025 |
#92 in Memory management
32 downloads per month
Used in events_once
545KB
9K
SLoC
Infinity Pool
Object pools with trait object support and multiple access models. Provides faster alternatives to Box::pin(), Arc::pin() and Rc::pin().
Pool types
- PinnedPool - basic object pool for a single type with pinned memory guarantees
- OpaquePool - for objects with unnameable types (e.g.
impl Future) - BlindPool - accepts multiple different types in the same pool
All pools support trait object casting.
Access models
Each pool type comes in three variants:
- Thread-safe with
Arc-style handles (default) - Single-threaded with
Rc-style handles (Local*variants) - Manual lifetime management (
Raw*variants)
Example
use std::fmt::Display;
use infinity_pool::{BlindPool, PinnedPool, define_pooled_dyn_cast};
// Enable casting to Display trait objects
define_pooled_dyn_cast!(Display);
fn main() {
// PinnedPool: thread-safe pool for a single type
let mut pinned_pool = PinnedPool::<String>::new();
let handle = pinned_pool.insert("Hello, PinnedPool!".to_string());
// Cast PinnedPool handle to trait object and pass to function
let display_pinned = handle.cast_display();
print_item("PinnedPool", &display_pinned);
// BlindPool: thread-safe pool for multiple types
let mut blind_pool = BlindPool::new();
let string_handle = blind_pool.insert("Hello, BlindPool!".to_string());
let number_handle = blind_pool.insert(42_i32);
// Cast to trait objects and pass to function that accepts AsRef<dyn Display>
let display_string = string_handle.cast_display();
let display_number = number_handle.cast_display();
print_item("BlindPool string", &display_string);
print_item("BlindPool number", &display_number);
}
/// Function that accepts anything that can be borrowed as a Display trait object
fn print_item(label: &str, item: &impl AsRef<dyn Display>) {
println!("{}: {}", label, item.as_ref());
}
More details in the package documentation.
This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.
Dependencies
~465–740KB
~14K SLoC