I have data that is versioned using SemVer. I have functions that have SemVer requirements, e.g. they support versions in the half-open interval [1.1, 2.0). In C++ I could do something like this:
struct Data_v1_0 {
// Added in V1.0
int a;
};
struct Data_v1_1 : public Data_v1_0 {
// Added in V1.1
int b;
}
void foo(const Data_v1_0& data) {
// Supports [1.0, 2.0)
print(data.a);
}
void bar(const Data_v1_1& data) {
// Supports [1.1, 2.0)
print(data.b);
}
Is there any way to do something similar in Rust?