title: How to move one field out of a struct that implements Drop trait?
body: <p>Here's an invalid Rust program (Rust version 1.1) with a function that does an HTTP client request and returns only the headers, dropping all other fields in the response.</p>
  
  <pre><code>extern crate hyper;
  
  fn just_the_headers() -&gt; Result&lt;hyper::header::Headers, hyper::error::Error&gt; {
      let c = hyper::client::Client::new();
      let result = c.get("http://www.example.com").send();
      match result {
          Err(e) =&gt; Err(e),
          Ok(response) =&gt; Ok(response.headers),
      }
  }
  
  fn main() {
      println!("{:?}", just_the_headers());
  }
  </code></pre>
  
  <p>Here are the compiler errors:</p>
  
  <pre class="lang-none prettyprint-override"><code>main.rs:8:28: 8:44 error: cannot move out of type `hyper::client::response::Response`, which defines the `Drop` trait
  main.rs:8         Ok(response) =&gt; Ok(response.headers),
                                   ^~~~~~~~~~~~~~~~
  error: aborting due to previous error
  </code></pre>
  
  <p>I understand <em>why</em> the borrow checker doesn't accept this program—i.e., that the <code>drop</code> function will use the <code>response</code> after it has had its <code>headers</code> member moved.</p>
  
  <p>My question is: How can I get around this and still have good safe Rust code? I know I can do a <em>copy</em>, via <code>clone()</code>, like so:</p>
  
  <pre><code>Ok(response) =&gt; Ok(response.headers.clone()),
  </code></pre>
  
  <p>But, coming from C++, that seems inefficient. Why <em>copy</em> when a <em>move</em> should suffice? I envision in C++ doing something like the following to force a call to a move constructor, if available:</p>
  
  <pre><code>headers_to_return = std::move(response.headers);
  </code></pre>
  
  <p>Is there any way to forgo the <em>copy</em> in Rust and instead force a <em>move</em>, similar to C++?</p>