title: Returning a struct containing mutable values
body: <p>I have the following code, where I'm trying to return the struct <code>Foo</code> with a set of default values for the field <code>values</code>. These values may be changed later. But the compiler complains:</p>
  
  <pre><code>error: `initial` does not live long enough
  </code></pre>
  
  <p>How this could be achieved? Any alternatives?</p>
  
  <pre class="lang-rust prettyprint-override"><code>struct Foo &lt;'a&gt; {
      values: &amp;'a mut Vec&lt;i32&gt;,
  }
  
  impl &lt;'a&gt; Foo &lt;'a&gt; {
      fn new() -&gt; Foo &lt;'a&gt; {
          let initial = vec![1, 2];
  
          Foo { values: &amp;mut initial }
      }
  }
  
  let my_foo = Foo::new();
  
  my_foo.values.push(3);
  </code></pre>