title: Create empty array with a length from a variable
body: <p>I want to read a custom amount of bytes from a <code>TcpStream</code>, but I cannot initialize a new empty array buffer where I can define the length with a variable. It is not possible to use a vector because the <code>TcpStream</code> read function requires an array.</p>
  
  <pre><code>let mut buffer = [0; 1024]; // The 1024 should be a variable
  </code></pre>
  
  <p>When I replace the <code>1024</code> with a variable:</p>
  
  <pre><code>let length = 2000;
  let mut buffer = [0; length];
  </code></pre>
  
  <p>I get the message:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0435]: attempt to use a non-constant value in a constant
  --&gt; src/network/mod.rs:26:30
  |
  26 |         let mut buffer = [0; bytes];
  |                              ^^^^^ non-constant used with constant
  </code></pre>
  
  <p>Why can't I do that?</p>