title: Generic struct over a generic type without type parameter
body: <p>Is it possible to do something like this in Rust?</p>
  
  <pre><code>trait Foo&lt;T&gt; {}
  
  struct A;
  struct B;
  
  struct Bar&lt;T: Foo&gt; {
      a: T&lt;A&gt;,
      b: T&lt;B&gt;
  }
  </code></pre>
  
  <p>I know I could just use two parameters for <code>Bar</code>, but I think there has to be a better way to do this.</p>
  
  <p>I want to implement a <code>Graph</code> structure. As I can't just bind the nodes and edges to their parents lifetime, I want to have something like <code>Rc</code>. However, sometimes one may need a <code>Graph</code> with access from multiple threads. So I'd have to have both an implementation with <code>Rc</code> and <code>Arc</code>.</p>
  
  <p>That's what <code>Foo</code> is good for: I implement <code>Foo</code> for both <code>Rc</code> and <code>Arc</code> (<code>Foo</code> would require <code>Deref</code>) and I use a parameter <code>T</code> bound to <code>Foo</code>. That's how I wanted to have one struct for single thread and multi thread usage.</p>