title: How to map a parametrized enum from a generic type to another?
body: <p>If I have a type like <code>MyEnum&lt;T&gt;</code>, how can I map it in cases where not every variant is parameterized?</p>
  
  <p>For example, I'd like to convert from <code>MyEnum&lt;u32&gt;</code> to <code>MyEnum&lt;String&gt;</code>:</p>
  
  <pre><code>enum MyEnum&lt;T&gt; {
      B,
      C,
      D(T),
  }
  
  fn trans(a: MyEnum&lt;u32&gt;) -&gt; MyEnum&lt;String&gt; {
      match a {
          MyEnum::D(i) =&gt; MyEnum::D(i.to_string()),
          other_cases =&gt; other_cases,
      }
  }
  
  fn main() {}
  </code></pre>
  
  <p>This fails with:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: match arms have incompatible types
    --&gt; src/main.rs:8:9
     |
  8  |         match a {
     |         ^ expected struct `std::string::String`, found u32
     |
     = note: expected type `MyEnum&lt;std::string::String&gt;`
     = note:    found type `MyEnum&lt;u32&gt;`
  note: match arm with an incompatible type
    --&gt; src/main.rs:10:28
     |
  10 |             other_cases =&gt; other_cases,
     |                            ^^^^^^^^^^^
  </code></pre>
  
  <p>Instead of the <code>other_cases =&gt; other_cases</code> line, I tried this, also without success:</p>
  
  <pre><code>other_cases =&gt; {
      let o: MyEnum&lt;String&gt; = other_cases;
      o
  }
  </code></pre>