EmbarkStudios / mirror-mirror

🪞 Powerful reflection library for Rust
Apache License 2.0
79 stars 2 forks source link

Make struct field iteration order consistent #98

Closed davidpdrsn closed 1 year ago

davidpdrsn commented 1 year ago

This took me all afternoon to find 😅 It caused issues in that internal system we have that starts with L and ends with X.

You can iterate over the fields in a struct either from a &dyn Struct or a StructType however the order was not consistent. When iterating over the fields in a value it used declaration order, whereas the type order was alphabetically. This fixes that so the type ordering is also based on the declaration.