title: When to use Rc vs Box?
body: <p>I have the following code which uses both <code>Rc</code> and <code>Box</code>; what is the difference between those? Which one is better?</p>
  <pre><code>use std::rc::Rc;
  
  fn main() {
      let a = Box::new(1);
      let a1 = &amp;a;
      let a2 = &amp;a;
      let b = Rc::new(1);
      let b1 = b.clone();
      let b2 = b.clone();
  
      println!(&quot;{} {}&quot;, a1, a2); //=&gt; 1 1
      println!(&quot;{} {}&quot;, b1, b2); //=&gt; 1 1
  }
  </code></pre>
  <p><a href="https://play.rust-lang.org/?gist=f969bf51c9ff678d7f7267794bf0218f&amp;version=stable" rel="noreferrer">playground link</a></p>