title: How can new members persist when pushing to a Vec in a for loop?
body: <p>I am trying to learn how to utilize objects in Rust by hacking away. The following code predictably gives "borrowed value does not live long enough" but I'm not sure what to change. What is the approach to creating a bunch of instances in a for loop that can then be access outside of it?</p>
  
  <pre><code>let mut vec_ducks: Vec&lt;&amp;Duck&gt; = vec![];
  
  for i in 0..100 {
      let _x = rand::thread_rng().gen_range(0, 100);
      let _y = rand::thread_rng().gen_range(0, 100);
  
      let duck = Duck { x: _x, y: _y };
  
      vec_ducks.push(&amp;duck);
  
      //println!("{}", i);
  }
  
  for d in &amp;vec_ducks {
      d.quack();
  }
  </code></pre>