title: Is there way to make stuct, contains inner references?
body: <p>How can I do something like that:</p>
  
  <pre class="lang-rust prettyprint-override"><code>    struct Parsed&lt;'a&gt; {
          bytes: Vec&lt;u8&gt;,
          h: &amp;'a [u8]
      }
      impl&lt;'a&gt; Parsed&lt;'a&gt; {
          fn new(bytes: Vec&lt;u8&gt;) -&gt; Self {
              let h = bytes.as_slice();
              Parsed {
                  bytes,
                  h,
              }
          }
      }
  </code></pre>
  
  <p>I need it for parsing messages with nom from tcp streams without copy objects.
  Cause I know size of messages, I can prepare some byte array for nom, but cannot return parsed messages to caller. I think it's a good idea to place buffer inside message struct, but it fail with rust borrow-checker :'(</p>
  
  <p>Borrow checker says as follows:</p>
  
  <pre><code>error[E0515]: cannot return value referencing function parameter `bytes`
     --&gt; src/main.rs:217:13
      |
  216 |               let h = bytes.as_slice();
      |                       ----- `bytes` is borrowed here
  217 | /             Parsed {
  218 | |                 bytes,
  219 | |                 h,
  220 | |             }
      | |_____________^ returns a value referencing data owned by the current function
  
  error[E0505]: cannot move out of `bytes` because it is borrowed
     --&gt; src/main.rs:218:17
      |
  214 |       impl&lt;'a&gt; Parsed&lt;'a&gt; {
      |            -- lifetime `'a` defined here
  215 |           fn new(bytes: Vec&lt;u8&gt;) -&gt; Self {
  216 |               let h = bytes.as_slice();
      |                       ----- borrow of `bytes` occurs here
  217 | /             Parsed {
  218 | |                 bytes,
      | |                 ^^^^^ move out of `bytes` occurs here
  219 | |                 h,
  220 | |             }
      | |_____________- returning this value requires that `bytes` is borrowed for `'a`
  </code></pre>