| Crates.io | infinity_pool |
| lib.rs | infinity_pool |
| version | 0.7.2 |
| created_at | 2025-09-07 11:13:42.216108+00 |
| updated_at | 2025-09-22 14:55:01.594537+00 |
| description | Offers object pooling capabilities both thread-safe and single threaded, both lifetime-managed and manual, both typed and untyped |
| homepage | |
| repository | https://github.com/folo-rs/folo |
| max_upload_size | |
| id | 1828036 |
| size | 736,515 |
Object pools with trait object support and multiple access models. Provides faster alternatives to Box::pin(), Arc::pin() and Rc::pin().
impl Future)All pools support trait object casting.
Each pool type comes in three variants:
Arc-style handles (default)Rc-style handles (Local* variants)Raw* variants)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.