title: Only implement support for a subset of types that implement a trait
body: <p>Sometimes in Rust, types implementing a trait depend on platform specifc behavior such that it's not possible to deal with them entirely generally through only the trait interface. In this case, it would be useful to implement general code once, and platform specific code on each concrete type.</p>
  
  <p>For example:</p>
  
  <pre class="lang-rust prettyprint-override"><code>trait IncompleteInterface {}
  
  struct PlatformA;
  struct PlatformB;
  
  impl IncompleteInterface for PlatformA {}
  impl IncompleteInterface for PlatformB {}
  
  impl PlatformA {
      fn baz() {}
  }
  
  impl PlatformB {
      fn fizz() {}
      fn buzz() {}
  }
  
  struct PlatformDependent&lt;T: IncompleteInterface&gt;(T);
  
  impl&lt;T /* Constrain to PlatformA and PlatformB */&gt; PlatformDependent&lt;T&gt; {
      fn foo() {
          Self::bar();
      }
  }
  
  impl PlatformDependent&lt;PlatformA&gt; {
      fn bar(&amp;self) {
          self.0.baz();
      }
  }
  
  impl PlatformDependent&lt;PlatformB&gt; {
      fn bar(&amp;self) {
          self.0.fizz();
          self.0.buzz();
      }
  }
  </code></pre>
  
  <p>Without a constraint, this can't compile, because the compiler can't be sure there is an appropriate implementation for <code>PlatformDependent::baz()</code>. For instance if, someone implements <code>impl IncompleteInterface for PlatformC {}</code>, then obviously <code>PlatformDependent&lt;C&gt;(platformC).bar()</code> won't work.</p>
  
  <p>Is there a way to tell the compiler the general implementation only works with Platforms A and B?</p>