enumkit-derive 0.0.0

Derive macros for enumkit.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 9.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 289.36 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • veggiebob/enumkit
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • veggiebob

enumkit-derive

This crate provides proc macros for use with enumkit:

  • #[derive(EnumValues)] – Adds a values() method that returns all unit enum variants.
  • #[derive(EnumMapping)] – Generates a struct mapping enum variants to values in a static array.

These macros only work with enums composed entirely of unit variants (i.e., variants with no associated data).


Usage

Add to your Cargo.toml:

[dependencies]
enumkit-derive = "<version>"

Then derive the macros on your enum:

use enumkit::{EnumValues, EnumMapping};

#[derive(EnumValues, EnumMapping)]
enum Mode {
    Fast,
    Slow,
    Sleep,
}

See enumkit for the trait definitions and runtime behavior.


Notes

  • These macros panic at compile time if used on non-unit enums.
  • Serialization support via serde is opt-in via feature flags in enumkit.

License

MIT or Apache-2.0