4 releases
0.1.4 | Apr 5, 2023 |
---|---|
0.1.3 | Apr 2, 2023 |
0.1.2 | Apr 2, 2023 |
0.1.1 |
|
0.1.0 | Apr 1, 2023 |
#1490 in Rust patterns
60 downloads per month
16KB
295 lines
Arena, fast and efficient storage enumeration
lib.rs
:
enums_arena
enums_arena
is an arena that enums can be stored efficiently
usage:
#[derive(PartialEq, Debug, Clone, Default)]
struct Click {
x: i32,
y: i32,
}
#[derive(enums_arena_derive::EnumsIdArena, PartialEq, Debug)]
enum Event {
Click(Click),
Tick(f32),
Close,
}
let mut arena = EventIdArena::<u32, ()>::default();
let id = arena.alloc_click(Click::default());
arena.alloc_tick(1f32);
arena.alloc_close();
assert_eq!(arena.get(id), Some(Event::Click(Click::default())));
arena.clear();
assert_eq!(arena.get(id), None);
Dependencies
~0.6–1MB
~21K SLoC