Peternator7 / strum

A small rust library for adding custom derives to enums
https://crates.io/crates/strum
MIT License
1.8k stars 152 forks source link

Adding a custom attribute to a type generated via `strum_discriminants` #375

Open alex35mil opened 2 months ago

alex35mil commented 2 months ago

I need to add a custom attribute to a type generated via strum_discriminants:

#[derive(EnumDiscriminants)]
#[strum_discriminants(
    name(MyEnumD),
    derive(CustomDerive),
    CustomAttr = "value" // <- it doesn't compile
)]
pub enum MyEnum { ... }

The result should be:

#[derive(CustomDerive)]
#[CustomAttr = "value"]
pub enum MyEnumD { ... }

How to do that?

tekacs commented 1 month ago

This would be super helpful to add #[wasm_bindgen] to the Discriminants variant of an enum!