stadium

Crates.iostadium
lib.rsstadium
version0.1.6
sourcesrc
created_at2021-01-06 13:15:08.75447
updated_at2021-03-15 14:09:43.695952
descriptionA allocated chunk of memory populated with a fixed set of types
homepage
repositoryhttps://github.com/gymore-io/stadium
max_upload_size
id333089
size47,768
Karl Tastroff (gymore-io)

documentation

https://docs.rs/stadium/

README

Documentation Crates.io

stadium provides the Stadium structure. This datastructure allows you to allocate any given set of objects (that can be of different types) in a continuous chunk of the memory.

Example

// The first step is to build the stadium using a builder.
// This registers the data that will be used inside of the stadium.
let mut builder = stadium::builder();

let h_vec = builder.insert(vec![2019, 2020, 2021]);
let h_str = builder.insert("Hello, world!");
let h_int_a = builder.insert(68u64);
let h_int_b = builder.insert(65u64)

// Once the initialization is done, the actual stadium can be created.
let mut stadium = builder.build();

// Values can be retrieved.
assert_eq!(&stadium[h_vec], &[2019, 2020, 2021][..]);
assert_eq!(stadium[h_str], "Hello, world!");
assert_eq!(stadium[h_int_a], 68);

// Or mutated.
stadium[h_vec].push(2022);
stadium[h_int_b] = 70;

// Other operations are supported.
assert_eq!(stadium.replace(h_str, "FOOBAR"), "Hello, world!");

stadium.swap(h_int_a, h_int_b);
assert_eq!(stadium[h_int_a], 70);
assert_eq!(stadium[h_int_b], 68);
Commit count: 33

cargo fmt