title: How to concatenate static slices in rust?
body: <p>I have two static slices of <code>u8</code> and I would implement a function to concatenate them. Something like that</p>
  <pre><code>fn concat_u8(first: &amp;'static [u8], second: &amp;'static [u8]) -&gt; &amp;'static [u8] {
      &amp;[&amp;first[..], &amp;second[..]].concat()
  }
  </code></pre>
  <p>The compiler shows me the error <code>returns a reference to data owned by the current function</code>. That because the allocated memory will be free at the end of the function.</p>
  <p>How can I &quot;force&quot; the lifetime to be static?</p>
  <p><strong>Edit</strong></p>
  <p>I've a long running process.</p>
  <p>At start time, the process processes some input in order to calculate a result (ie <code>concat_u8</code> function). The result is a slice of <code>u8</code> and will be used in the rest of the process life in read-only.
  The function <code>concat_u8</code> couldn't be called after an &quot;internal <code>start</code> event&quot;.</p>
  <p>I'd like not to use <code>Box</code> because the dynamic allocation implies a little overhead (maybe not measurable?) and store the result as <code>&amp;[u8]</code>.</p>
  <p>Have I any chance to do that?</p>
  <p>Have I any chance to do that without using an <code>unsafe</code> block?</p>