title: Rust - How are 'String' and 'str' different in memory?
body: <p>I have seen <a href="https://stackoverflow.com/questions/24158114/what-are-the-differences-between-rusts-string-and-str">this</a> question, but still didn't get it, so here's what I know (it might be incorrect):</p>
  <ul>
  <li>Initializing a variable of type <code>String</code> allocates memory on the <em>heap</em> and stores a pointer to that memory on the <em>stack</em>.</li>
  <li>Initializing a variable of type <code>&amp;str</code> stores a pointer on the <em>stack</em>, and I'm assuming that pointer <strong>points</strong> to a <code>str</code> on the <em>heap</em>.</li>
  </ul>
  <p>If that's the case - if both <code>String</code> and <code>&amp;str</code> store pointers on the stack <strong>pointing</strong> to memory locations on the heap - does that mean <code>String</code> and <code>str</code> (not the reference) are the same?</p>