title: Is it possible for one struct to extend an existing struct, keeping all the fields?
body: <p>Using <code>rust 1.2.0</code></p>
  
  <p><strong>Problem</strong></p>
  
  <p>I'm still in the process of learning Rust (coming from a Javascript background) and am trying to figure out if it is possible for one struct <code>StructB</code> to extend an existing struct <code>StructA</code> such that <code>StructB</code> has all the fields defined on <code>StructA</code>.</p>
  
  <p>In Javascript (ES6 syntax) I could essentially do something like this...</p>
  
  <pre><code>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;
      }
  }
  </code></pre>
  
  <p><strong>Constraints</strong></p>
  
  <ul>
  <li><code>StructA</code> is from an external <code>cargo</code> package that I have no control over.</li>
  </ul>
  
  <p><strong>Current Progress</strong></p>
  
  <p>I found this <a href="http://smallcultfollowing.com/babysteps/blog/2013/10/24/single-inheritance/" rel="noreferrer">blog post on single-inheritance</a> which sounds like exactly what I need.</p>
  
  <p>But trying to implement it resulted in this error message <code>error: virtual structs have been removed from the language</code>. Some searching later and I found out that it had been <a href="https://github.com/rust-lang/rfcs/blob/master/text/0341-remove-virtual-structs.md" rel="noreferrer">implemented and then removed per RFC-341</a> rather quickly.</p>
  
  <p>Also found this <a href="https://users.rust-lang.org/t/oop-how-to-override/1980" rel="noreferrer">thread about using traits</a>, but since <code>StructA</code> is from an external cargo package I don't think it is possible for me to turn it into a trait.</p>
  
  <p>So what would be the correct way to accomplish this in Rust?</p>