title: returns a value referencing data owned by the current function
body: <p>This code is throwing an error about returning a reference from the function:</p>
  <pre><code>fn sha512_256_digest(str: &amp;[u8]) -&gt; &amp;[u8] {
      let x = digest::digest(&amp;digest::SHA512_256, str);
      x.as_ref()
  }
  </code></pre>
  <p>What would be the correct way to return the <em>as_ref()</em> value of <em>x</em> here?</p>