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

Make derive macros and traits available from a single crate #249

Closed spearman closed 1 year ago

spearman commented 1 year ago

It would be slightly nicer to only need to add a single dependency. As it is now, to use strum_macros you must import strum anyway (so it seems). Other crates that provide similar macros don't require depending on separate macro/trait crates (examples are the enum-iterator crate and the parse-display crate), although they do include a procedural macros crate as a dependency of the main crate. Just a suggestion for future versions. Feel free to close this issue if you feel it's not relevant.

Peternator7 commented 1 year ago

At the moment, you can add a derive feature to strum to import both strum and the macros

[dependencies]
strum = { version="0.24", features=["derive"] }

They could probably be one crate, but serde uses the pattern above so that's the route I opted for as well. As a minor benefit, it means that if you're using a derive macro that doesn't reference any of strum's traits, you don't need to reference strum itself anywhere. Only strum_macros.

spearman commented 1 year ago

That's perfect, that's how serde does it. Looks like the feature was mentioned in the readme but I overlooked it. I'll go ahead and close this.