sigp / superstruct

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

Stabilise enum ordering #6

Closed michaelsproul closed 3 years ago

michaelsproul commented 3 years ago

The HashMap used for the variants attribute randomises the ordering of enum variants, which is quite unintuitive and doesn't interact nicely with e.g. serde's untagged enum deserialisation which relies on ordering: https://serde.rs/enum-representations.html#untagged

Using a wrapper around Vec we could impose the ordering provided in the top-level superstruct(variants(..)) attribute