title: Is there a way to use match() in rust when modifying the selector?
body: <p>This question is badly named, but basically, consider this simplistic example:</p>
  
  <p>You have a linked list in the form:</p>
  
  <pre class="lang-rust prettyprint-override"><code>struct Node&lt;T&gt; {
      _next: Option&lt;~Node&lt;T&gt;&gt;,
      _data: Option&lt;T&gt;
  }
  </code></pre>
  
  <p>And a 'push' operation that adds elements to the chain:</p>
  
  <pre class="lang-rust prettyprint-override"><code>/** Attach a node as the 'next' node in this chain */
  fn push&lt;'a&gt;(&amp;'a mut self, value: T) -&gt; &amp;'a mut ~Node&lt;T&gt; {
      if (self._next.is_none()) {
          self._push_node(~Node::new(value));
      } else {
          let tmp = self._next.take().unwrap();
          let mut next = ~Node::new(value);
          next._push_node(tmp);
          self._push_node(next);
      }
      return self._next.as_mut().unwrap();
  }
  </code></pre>
  
  <p>This works, but it feels like it would be neater as a match() expression instead of an if statement, something like:</p>
  
  <pre class="lang-rust prettyprint-override"><code>/** Attach a node as the 'next' node in this chain */
  fn push&lt;'a&gt;(&amp;'a mut self, value: T) -&gt; &amp;'a mut ~Node&lt;T&gt; {
      match self._next {
          None =&gt; { self._push_node(~Node::new(value)); },
          Some(ref v)  =&gt; { &lt;----------------------------- :(
              let tmp = self._next.take().unwrap(); &lt;------- ???
              let mut next = ~Node::new(value);
              next._push_node(tmp);
              self._push_node(next);
          }
      }
      return self._next.as_mut().unwrap();
  }
  </code></pre>
  
  <p>However, this won't work because of the line indicated above; effectively we're modifying the value of _next, which can't happen because we've borrowed self._next for the scope of the match statement's Some().</p>
  
  <p>Is there a better way of doing this?</p>
  
  <p>Can you somehow declare a match statement purely as a match, so that once you're inside the Some() => { ... } block you are <em>not</em> borrowing the value?</p>