Crates.io | type-pools |
lib.rs | type-pools |
version | 0.1.0 |
source | src |
created_at | 2024-05-15 19:51:38.751301 |
updated_at | 2024-05-15 19:51:38.751301 |
description | A data structure to store values of multiple types |
homepage | https://github.com/jomy10/type-pools |
repository | https://github.com/jomy10/type-pools |
max_upload_size | |
id | 1241442 |
size | 8,488 |
Type pools are a data structure for storing values of multiple types. Values can be queried from their type.
// Create a Type Pools structure
let mut pools = TypePools::new();
// Adding values
pools.push(1 as u32);
pools.push(2 as u32);
pools.push("Hello world");
// Query values
let int_pool = pools.type_pool::<u32>().unwrap();
let int_value: u32 = int_pool.values[0];
let string_value: &str = pools.get(0).unwrap();
The library is licensed under the MIT license