title: Rust limits of const functions
body: <p>In Rust, <code>const</code> functions are quite limited in what code can be put inside them, e.g. <code>for</code> loops aren't allowed, nor are any non-<code>const</code> function calls. I understand that there are issues with heap allocations in <code>const</code> functions, but why is it that for example the below code isn't valid:</p>
  <pre class="lang-rust prettyprint-override"><code>fn add(a: u8, b: u8) -&gt; u8 {
      a + b
  }
  const A: u8 = add(1, 2);
  </code></pre>
  <p>This would be valid if <code>add</code> was declared as a <code>const</code> function, so I don't why the Rust compiler can't detect that this is valid; so I guess I'm also asking why <code>const</code> functions are necessary at all, and why even <code>for</code> loops aren't allowed inside them (even though while loops are).</p>