Using rust 1.2.0
Problem
I'm still learning Rust (based on Javascript background) and trying to figure out if it is possible for a single StructB structure StructB extend the existing StructA structure StructA that StructB all fields defined on StructA .
In Javascript (ES6 syntax), I could essentially do something like this ...
class Person { constructor (gender, age) { this.gender = gender; this.age = age; } } class Child extends Person { constructor (name, gender, age) { super(gender, age); this.name = name; } }
Limitations
StructA is an external cargo package that I do not control.
Current progress
I found this single inheritance blog post that sounds like exactly what I need.
But an attempt to implement it led to this error message error: virtual structs have been removed from the language . Some searches later, and I found out that it was implemented and then deleted in RFC-341 pretty quickly.
This thread was also found on the use of signs , but since StructA from an external load package, I do not think it is possible for me to turn it into a dash.
So what would be the right way to do this in Rust?
source share