title: Is there any way I can allow a generic function to use specialized functions?
body: <p>I have the following code:</p>
  
  <pre><code>use std::marker::PhantomData;
  
  struct Magic&lt;T&gt; {
      phantom: PhantomData&lt;T&gt;,
  }
  
  struct A;
  struct B;
  
  impl Magic&lt;A&gt; {
      fn value() -&gt; i32 {
          5
      }
  }
  
  impl Magic&lt;B&gt; {
      fn value() -&gt; i32 {
          10
      }
  }
  
  impl&lt;T&gt; Magic&lt;T&gt; {
      fn extra() -&gt; i32 {
          Magic::&lt;T&gt;::value() + 5
      }
  }
  
  fn main() {}
  </code></pre>
  
  <p>It fails:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0599]: no function or associated item named `value` found for type `Magic&lt;T&gt;` in the current scope
    --&gt; src/main.rs:25:9
     |
  3  | struct Magic&lt;T&gt; {
     | --------------- function or associated item `value` not found for this
  ...
  25 |         Magic::&lt;T&gt;::value() + 5
     |         ^^^^^^^^^^^^^^^^^ function or associated item not found in `Magic&lt;T&gt;`
  </code></pre>
  
  <p>This makes sense because <code>T</code> isn't necessarily <code>A</code> or <code>B</code>. However, when I call this function, I am confident that it will always be either <code>A</code> or <code>B</code>. </p>
  
  <p>Knowing this, is there any way I can allow this generic function to use these specialized functions?</p>