I’ve been building a lot of micro-services using Rust, and one of the biggest remaining pain-points is around data manipulation.
Often I will have a big hierarchy of related data types which are used as part of an API, and maybe stored in a database. The problem is that I’d like to evolve those data types over time: fields will be added/removed etc. and I need to maintain backwards compatibility.
At the moment, the only way to do that is to duplicate the entire set of data-types into a new module, and then painstakingly implement conversions between the two, even though most of the types are completely unchanged.
I wanted to see if people had any ideas for solutions to this problem? I’ve thought about various kinds of code-gen or procedural macro solutions, but the nature of the problem means they end up being very restrictive, incredibly complicated to implement, and also kill compile times by generating huge amounts of code.
One thing that could help a little would be expanding the “spread” operator to work across different types, as long as the fields were the same, but that alone is insufficient - you’d also need to be able to apply “into” conversions on all of the fields being spread.