title: Vector of Generic Structs in Rust
body: <p>I am creating an entity component system in Rust, and I would like to be able to store a <code>Vec</code> of components for each different <code>Component</code> type:</p>
  
  <pre><code>pub trait Component {}
  
  struct ComponentList&lt;T: Component&gt; {
      components: Vec&lt;T&gt;,
  }
  </code></pre>
  
  <p>Is it possible to create a collection of these <code>ComponentList</code>s?</p>
  
  <pre><code>struct ComponentManager {
      component_lists: Vec&lt;ComponentList&lt;_&gt;&gt;, // This does not work
  }
  </code></pre>
  
  <p>This is intended to make it faster to retrieve a list of a certain <code>Component</code> type, as all instances of a certain type of component will be in the same <code>ComponentList</code>.</p>