How to bind multiple struct fields without getting "use moved value" error? <p>I'm trying to code a generic list as an exercise - I know it's already supported by the syntax, I'm just trying to see if I can code a recursive data structure. As it turns out, I can't. I'm hitting a wall when I want to access more than one field of an owned struct value.</p> <p>What I'm doing is basically this - I define a struct that will hold a list:</p> <pre class="lang-rust prettyprint-override"><code>struct ListNode&lt;T&gt; { val: T, tail: List&lt;T&gt; } struct List&lt;T&gt;(Option&lt;Box&lt;ListNode&lt;T&gt;&gt;&gt;); </code></pre> <p>Empty list is just represented by <code>List(None)</code>.</p> <p>Now, I want to be able to append to a list:</p> <pre><code>impl&lt;T&gt; List&lt;T&gt; { fn append(self, val: T) -&gt; List&lt;T&gt; { match self { List(None) =&gt; List(Some(Box::new(ListNode { val: val, tail: List(None) }))), List(Some(node)) =&gt; List(Some(Box::new(ListNode { val: node.val, tail: node.tail.append(val) }))) } } } </code></pre> <p>Ok, so that fails with an error "used of moved value: node" at node.tail with an explanation that it was moved at "node.val". This is understandable.</p> <p>So, I look for ways to use more than one field of a struct and I find this: <a href="https://mail.mozilla.org/pipermail/rust-dev/2014-January/008216.html">Avoiding partially moved values error when consuming a struct with multiple fields</a></p> <p>Great, so I'll do that:</p> <pre><code>List(Some(node)) =&gt; { let ListNode { val: nval, tail: ntail } = *node; List(Some(Box::new(ListNode { val: nval, tail: ntail.append(val) }))) } </code></pre> <p>Well, nope, still node is being moved at assignment ("error: use of moved value 'node'" at "tail: ntail"). Apparently this doesn't work like in the link anymore.</p> <p>I've also tried using refs:</p> <pre><code>List(Some(node)) =&gt; { let ListNode { val: ref nval, tail: ref ntail } = *node; List(Some(Box::new(ListNode { val: *nval, tail: (*ntail).append(val) }))) } </code></pre> <p>This time the deconstruction passes, but the creation of the new node fails with "error: cannot move out of borrowed content".</p> <p>Am I missing something obvious here? If not, what is the proper way to access multiple fields of a struct that is not passed by reference?</p> <p>Thanks in advance for any help!</p> <p>EDIT: Oh, I should probably add that I'm using Rust 1.1 stable.</p>