title: Why does moving a subcomponent of a Box consume the whole Box while moving a subcomponent of struct doesn't?
body: <p>Consider the following examples taken from <a href="http://cglab.ca/~abeinges/blah/too-many-lists/book/first-pop.html" rel="nofollow noreferrer"><em>Learning Rust With Entirely Too Many Linked Lists</em></a></p>
  
  <p>Example 1 <a href="https://play.rust-lang.org/?gist=5b37dd62632ea0ec94f8b9563f8817ce&amp;version=undefined&amp;mode=undefined" rel="nofollow noreferrer">rust playground</a></p>
  
  <pre><code>pub fn pop(&amp;mut self) -&gt; Option&lt;i32&gt; {
      match mem::replace(&amp;mut self.head, Link::Empty) {
          Link::Empty =&gt; None,
          Link::More(boxed_node) =&gt; {
              let node = *boxed_node;
              self.head = node.next;
              //println!("{:?}", node); // Adding this line will induce the same error
              Some(node.elem)
          }
      }
  }
  </code></pre>
  
  <p>Example 2 <a href="https://play.rust-lang.org/?gist=69588dd6f8afea91ee36dedbe275d919&amp;version=stable&amp;mode=debug" rel="nofollow noreferrer">rust playground</a></p>
  
  <pre><code>pub fn pop(&amp;mut self) -&gt; Option&lt;i32&gt; {
      match mem::replace(&amp;mut self.head, Link::Empty) {
          Link::Empty =&gt; None,
          Link::More(node) =&gt; {
              self.head = node.next;
              Some(node.elem)
          }
      }
  }
  </code></pre>
  
  <p>Error from example 2</p>
  
  <pre><code>error[E0382]: use of moved value: `node`
    --&gt; src/main.rs:42:20
     |
  41 |                     self.head = node.next;
     |                                 --------- value moved here
  42 |                     Some(node.elem)
     |                          ^^^^^^^^^ value used here after move
     |
     = note: move occurs because `node.next` has type `main::Link`, which does not implement the `Copy` trait
  </code></pre>
  
  <p>With the following types</p>
  
  <pre><code>struct Node {
      elem: i32,
      next: Link,
  }
  
  enum Link {
      Empty,
      More(Box&lt;Node&gt;),
  }
  </code></pre>
  
  <p>In example 1, the content of the <code>Box</code> (e.g. struct) is first moved to <code>node</code> then part of the struct is moved to <code>head</code></p>
  
  <p>In example 2, part of the <code>Box</code> is moved to <code>head</code>.</p>
  
  <p>Why doesn't example 1 have the same compiler error as example 2? Specifically, if I move part of a struct why doesn't it consume the entire struct?</p>