title: How to clone a Box<CustomStruct> when I keep getting "no method named clone"?
body: <p>I want to clone <code>head</code> which is a <code>Box&lt;Node&lt;T&gt;&gt;</code>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>let mut node = Some((*head).clone());
  </code></pre>
  
  <p>Here is the full code (<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=b6d1378cca1608335a84924bc6529124" rel="nofollow noreferrer">playground</a>): </p>
  
  <pre class="lang-rust prettyprint-override"><code>use std::boxed::Box;
  
  pub struct List&lt;T&gt; {
      pub head: Option&lt;Box&lt;Node&lt;T&gt;&gt;&gt;,
      pub size: u64,
  }
  
  impl&lt;T&gt; List&lt;T&gt; {
      pub fn new() -&gt; List&lt;T&gt; {
          return List {
              head: Option::None,
              size: 0,
          };
      }
  
      pub fn push_back(&amp;mut self, data: T) {
          match &amp;self.head {
              Some(head) =&gt; {
                  let mut node = Some((*head).clone());
                  while (*(node).unwrap()).next.is_some() {
                      node = (*node.unwrap()).next;
                  }
                  node.unwrap().next = Some(Box::new(Node::new(data)));
              }
              None =&gt; {
                  self.head = Some(Box::new(Node::new(data)));
              }
          }
      }
  }
  
  #[derive(Clone)]
  pub struct Node&lt;T&gt; {
      pub next: Option&lt;Box&lt;Node&lt;T&gt;&gt;&gt;,
      pub value: T,
  }
  
  impl&lt;T&gt; Node&lt;T&gt; {
      pub fn new(v: T) -&gt; Node&lt;T&gt; {
          Node {
              next: Option::None,
              value: v,
          }
      }
  }
  </code></pre>
  
  <p>The compiler keeps saying the method <code>clone</code> exists but the following trait bounds were not satisfied:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0599]: no method named `clone` found for type `std::boxed::Box&lt;Node&lt;T&gt;&gt;` in the current scope
    --&gt; src/lib.rs:19:45
     |
  19 |                 let mut node = Some((*head).clone());
     |                                             ^^^^^
     |
     = note: the method `clone` exists but the following trait bounds were not satisfied:
             `Node&lt;T&gt; : std::clone::Clone`
             `std::boxed::Box&lt;Node&lt;T&gt;&gt; : std::clone::Clone`
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `clone`, perhaps you need to implement it:
             candidate #1: `std::clone::Clone`
  </code></pre>
  
  <p>I tried to add <code>#[derive(Clone)]</code> but it still doesn't work:</p>
  
  <pre class="lang-rust prettyprint-override"><code>#[derive(Clone)]
  pub struct Node&lt;T&gt; {
      pub next: Option&lt;Box&lt;Node&lt;T&gt;&gt;&gt;,
      pub value: T
  }
  </code></pre>
  
  <p>How can I do this? </p>