#variant #enums #struct #map #store #macro-derive

macro variant-map-derive

derive macro for the variant-map crate, adds another type called StructMap

1 unstable release

0.1.0 Sep 6, 2023

#116 in #enum

34 downloads per month
Used in variant-map

MIT license

43KB
828 lines

variant-map-derive

Enum variants stored in Maps.

Provides derive macros for variant_map

Includes a StructMap which is a struct with a field per variant of the enum

Pro: This struct has instant access to the fields (compared to the other Maps that need a lookup)

Con: Restricted API

Example

    use variant_map_derive::VariantStore;

    #[derive(VariantStore)]
    enum MyEnum {
        A,
        B(i32),
    }

For more detailed examples check out the example project on this crates' repo


lib.rs:

Enum variants stored in Maps.

Provides derive macros for variant_map

Includes a StructMap which is a struct with a field per variant of the enum

Pro: This struct has instant access to the fields (compared to the other Maps that need a lookup)

Con: Restricted API

Example

    use variant_map_derive::VariantStore;

    #[derive(VariantStore)]
    enum MyEnum {
        A,
        B(i32),
    }

For more detailed examples check out the example project on this crates' repo

Dependencies

~0.8–1.4MB
~31K SLoC