variant-set
variant-set provides a set-like data structure for enum variants. It allows you to store at most one value for each variant of an enum,
providing efficient storage and retrieval based on enum variants.
Use-case
Suppose you have a large, complex enum such as the following:
You could store the data of this enum like so:
However, the size of this struct is the sum of the sizes of all the fields, even if only one field is actually used. For large enough structs, this can be inefficient.
You effectively want a HashSet<MyEnum> where you can store at most one value for each variant. However, you do not care about the
specific value stored for each variant, only that you can store and retrieve it efficiently based on the variant itself.
This is what variant-set provides. Just derive the VariantEnum trait for your enum, and you can use the VariantSet data structure:
use ;
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
API Documentation
See the docs.rs documentation here.
Contributing
Contributions are welcome! Please feel free to open an issue or a pull request on GitHub.
License
This project is licensed under the CC0 License - see the LICENSE file for details.