varset

Crates.iovarset
lib.rsvarset
version0.2.1
created_at2024-10-25 18:15:44.882003+00
updated_at2024-10-28 17:31:08.865195+00
descriptionan any type set of items
homepage
repositoryhttps://github.com/jjmartinodev/varset
max_upload_size
id1422785
size6,149
Juan Cruz Martino (jjmartinodev)

documentation

README

VarSet

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.

Goal

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;


Commit count: 6

cargo fmt