Joining a thread in a method that takes `&mut self` (like drop) results in "cannot move out of borrowed content"
<p>I want to create a thread inside of the <code>new</code> method and stop it after the struct is destroyed:</p>

<pre><code>use std::thread;

struct Foo {
    handle: thread::JoinHandle&lt;()&gt;,
}

impl Foo {
    pub fn new(name: &amp;str) -&gt; Foo {
        let name = name.to_string();
        Foo {
            handle: thread::spawn(move || {
                println!("hi {}", name);
            }),
        }
    }
    pub fn stop(&amp;mut self) {
        self.handle.join();
    }
}

fn main() {
    let mut foo = Foo::new("test");
    foo.stop();
}
</code></pre>

<p>This doesn't compile, and I can not understand why:</p>

<pre class="lang-none prettyprint-override"><code>error[E0507]: cannot move out of borrowed content
  --&gt; &lt;anon&gt;:15:9
   |
15 |         self.handle.join();
   |         ^^^^ cannot move out of borrowed content
</code></pre>

<p>And in newer versions of Rust:</p>

<pre class="lang-none prettyprint-override"><code>error[E0507]: cannot move out of `self.handle` which is behind a mutable reference
  --&gt; src/main.rs:17:9
   |
17 |         self.handle.join();
   |         ^^^^^^^^^^^ move occurs because `self.handle` has type `std::thread::JoinHandle&lt;()&gt;`, which does not implement the `Copy` trait
</code></pre>

<p>How can I fix this error?</p>

<p>In the future, I will implement <code>Drop</code> for <code>Foo</code>, and will call <code>stop()</code> from <code>drop()</code>. </p>