title: Store reference of struct in other struct
body: <p>I have two structs. <code>App</code> and <code>Item</code>.</p>
  
  <p>What I want to achieve is to store an <code>Item</code> in the <code>items</code> vector of the <code>App</code> struct by passing a mutable reference to the <code>Item</code>s constructor.</p>
  
  <pre class="lang-rust prettyprint-override"><code>pub struct App&lt;'a&gt; {
      items: Vec&lt;&amp;'a Item&gt;
  }
  
  impl&lt;'a&gt; App&lt;'a&gt; {
      pub fn new() -&gt; App&lt;'a&gt; {
          App { items: Vec::new() }
      }
      pub fn register_item(&amp;mut self, item: &amp;'a Item) {
          self.items.push(item);
      }
  }
  
  pub struct Item;
  
  impl Item {
      pub fn new(app: &amp;mut App) -&gt; Item {
          let item = Item;
          app.register_item(&amp;item);
          item
      }
  }
  
  fn main() {
      let mut app = App::new();
  
      let item = Item::new(&amp;mut app);;
  }
  </code></pre>
  
  <p>The code thows the following error:</p>
  
  <pre><code>test.rs:8:28: 8:32 error: `item` does not live long enough
  test.rs:8         app.register_item(&amp;item);
  </code></pre>
  
  <p>Is there any way to do this?</p>