title: Lifetimes of references in mutable Vector
body: <p>I have an algorithm like:</p>
  
  <pre><code>let seed: Foo = ...
  let mut stack: Vec&lt;&amp;Foo&gt; = Vec::new();
  stack.push(&amp;seed);
  while let Some(next) = stack.pop {
      let more_foos: Vec&lt;Foo&gt; = some_function_of(next) // 0 to many Foos returned
      for foo in more_foos {
          stack.push(&amp;foo);
      }
  }
  </code></pre>
  
  <p>I receive the error that <code>foo</code> does not live long enough. I assume this is because <code>stack</code> has a greater lifetime. How can I fix this?</p>