enum_dict
A Rust library for efficient enum-indexed dictionaries.
Installation
Add to your Cargo.toml:
[]
= { = "0.3", = ["full"] }
Quick Start
use ;
Serde Support
With the serde feature enabled, RequiredDict and OptionalDict can be serialized and deserialized using serde:
use ;
use ;
Extra keys in the serialized data are ignored during deserialization.
Why enum_dict?
Compared to traditional HashMap approach, enum_dict uses Vec under the hood, allowing for:
- Direct Indexing: Access values with
dict[key]instead ofdict.get(&key). - Performance: Faster access times due to contiguous memory layout.
- Type Safety: Compile-time checks ensure all enum variants are handled.
- Simplicity: Less boilerplate code for common use cases.