title: How to use another array's length to initialize an array in Rust?
body: <p>I want to initialize an array whose length is equal to another array's length:</p>
  
  <pre><code>fn foo(array: &amp;[i32]) {
      let mut sum = [0; array.len()];
  }
  </code></pre>
  
  <p>It will make an error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0080]: constant evaluation error
    --&gt; test.rs:22:18
     |
  22 |    let mut sum = [0; array.len()];
     |                      ^^^^^^^^^^^ unsupported constant expr
  </code></pre>
  
  <p>I think I must use this <code>len()</code> argument... How can I solve this?</p>