title: Why is it legal to borrow a temporary?
body: <p>Coming from C++, I'm rather surprised that this code is valid in Rust:</p>
  
  <pre><code>let x = &amp;mut String::new();
  x.push_str("Hello!");
  </code></pre>
  
  <p>In C++, you can't take the address of a temporary, and a temporary won't outlive the expression it appears in.</p>
  
  <p>How long does the temporary live in Rust?  And since <code>x</code> is only a borrow, who is the owner of the string?</p>