title: How do I collect into an array?
body: <p>I want to call <code>.map()</code> on an array of enums:</p>
  
  <pre><code>enum Foo {
      Value(i32),
      Nothing,
  }
  
  fn main() {
      let bar = [1, 2, 3];
      let foos = bar.iter().map(|x| Foo::Value(*x)).collect::&lt;[Foo; 3]&gt;();
  }
  </code></pre>
  
  <p>but the compiler complains:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0277]: the trait bound `[Foo; 3]: std::iter::FromIterator&lt;Foo&gt;` is not satisfied
   --&gt; src/main.rs:8:51
    |
  8 |     let foos = bar.iter().map(|x| Foo::Value(*x)).collect::&lt;[Foo; 3]&gt;();
    |                                                   ^^^^^^^ a collection of type `[Foo; 3]` cannot be built from an iterator over elements of type `Foo`
    |
    = help: the trait `std::iter::FromIterator&lt;Foo&gt;` is not implemented for `[Foo; 3]`
  </code></pre>
  
  <p>How do I do this?</p>