Crates.io | varset |
lib.rs | varset |
version | |
source | src |
created_at | 2024-10-25 18:15:44.882003 |
updated_at | 2024-10-28 17:31:08.865195 |
description | an any type set of items |
homepage | |
repository | https://github.com/jjmartinodev/varset |
max_upload_size | |
id | 1422785 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A container structure for storing Any types in a set.
The container is implemented with a HashMap<TypeId,Box<Any>>
, so data in the container is not adyacent(cache misses increase) and to reach a single item there is a two pointer indirection. because of the problems mentioned before performance isn't as fast as it could be.
The goal is to create a type that can hold a compact and performant container, more specificaly, a kind of Vec<Any>
.
struct T {
number: u32,
list: Vec<u8>,
}
let mut set = VarSet::new();
set.insert(0u32);
set.insert(String::from("hiii"));
set.insert(T {
number: 123,
list: vec![1, 2, 3],
});
*set.get_mut::<u32>().unwrap() = 445;
(*set.get_mut::<String>().unwrap()).push_str(" everyone!!");
(*set.get_mut::<T>().unwrap()).list = vec![3,2,1];
(*set.get_mut::<T>().unwrap()).number = 4325;