[![crates.io](https://img.shields.io/crates/v/indexed_valued_enums.svg)](https://crates.io/crates/indexed_valued_enums)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/JorgeRicoVivas/indexed_valued_enums/rust.yml)](https://github.com/JorgeRicoVivas/indexed_valued_enums/actions)
[![docs.rs](https://img.shields.io/docsrs/indexed_valued_enums)](https://docs.rs/indexed_valued_enums/latest/indexed_valued_enums/)
[![GitHub License](https://img.shields.io/github/license/JorgeRicoVivas/indexed_valued_enums)](https://github.com/JorgeRicoVivas/indexed_valued_enums?tab=CC0-1.0-1-ov-file)

This crate makes easier to associate values to variant's of an enum while not incurring a slowdown in runtime, and
also to get the variant back from the value.

This crate gives you the following derive macros for this:
- ``EnumIndexed``: This gives you functions for getting the index and name of every variant, and get the variant
back from either the index or the name. This is done by implementing the ``Indexed``, ``IndexedWithVariant``, and
``Fieldless`` traits, and it gives you the following functions:
  - ``const fn variant_index(&self) -> usize``, this is O(1).
  - ``const fn from_variant_index(index: usize) -> Option<Self>``, this is O(1).
  - ``const fn variant_name(&self) -> &'static str``, this is O(1).
  - ``const fn from_variant_name(search: &str) -> Option<Self>``, this is **O(N)**.

- ``EnumValued``: This macro turns functions with the signature ``fn *function_name*(&self) -> *TypeOfValue*`` into
O(1) functions. It also gives you a ``fn from_*name of function*(value: &*associated type*) -> Option<Self>``
function, which is O(N).

- ``EnumValuedFromCSV``: Similar to ``EnumValued``, but you can specify the values of the variants in a CSV file.

You can find a full description and examples inside the documentation of each of these macros.

Note for users of ``1.X.X``: The ``2.X.X`` version offers no backward compatibility with ``1.X.X``, as ``1.X.X`` was 
arduous to use for end-users.