sigp / superstruct

Rust library for versioned data types
https://sigp.github.io/superstruct/
Apache License 2.0
65 stars 3 forks source link

Implement variant-specific attributes #27

Closed michaelsproul closed 1 year ago

michaelsproul commented 1 year ago

This PR adds support for applying different attributes to each variant. I want this primarily to integrate with a new library I'm working on, metastruct, which could be used to generate field mapping macros for superstruct variant structs. Each macro needs a unique name, so we need to make a different metastruct call for each variant.

There's an example of metastruct usage here: https://github.com/sigp/metastruct/blob/662cde78840c6cdfd6e688c155b87c6b4f1300d2/examples/hello_world.rs#L3-L6