title: Rust "future cannot be sent between threads safely"
body: <p>I'm invoking an async implemented method:</p>
  <pre class="lang-rust prettyprint-override"><code>let mut safebrowsing: MutexGuard&lt;Safebrowsing&gt; = self.safebrowsing.lock().unwrap();
  safebrowsing.is_safe(input: &amp;message.content).await;
  </code></pre>
  <p>The <strong>is_safe</strong>-Method:</p>
  <pre class="lang-rust prettyprint-override"><code>pub async fn is_safe(&amp;mut self, input: &amp;str) {
      let links = self.finder.links(input);
  
      for link in links {
          match reqwest::get(&quot;url&quot;).await {
              Ok(response) =&gt; {
                  println!(
                      &quot;{}&quot;,
                      response.text().await.expect(&quot;response has no content&quot;)
                  );
              }
              Err(_) =&gt; {
                  println!(&quot;Unable to get safebrowsing-response&quot;)
              }
          }
      }
  }
  </code></pre>
  <p>But unfortunately by invoking the <strong>is_safe</strong>-Method asynchronously, the compiler tells me that threads cannot be sent safely. The error is about:</p>
  <pre class="lang-none prettyprint-override"><code>future cannot be sent between threads safely
  within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard&lt;'_, Safebrowsing&gt;`
  required for the cast to the object type `dyn std::future::Future&lt;Output = ()&gt; + std::marker::Send`
  
  handler.rs(31, 9): future is not `Send` as this value is used across an await
             ^-- safebrowsing.is_safe(input: &amp;message.content).await;
  ---
  
  future cannot be sent between threads safely
  the trait `std::marker::Send` is not implemented for `(dyn for&lt;'r&gt; Fn(&amp;'r [u8]) -&gt; Option&lt;usize&gt; + 'static)`
  required for the cast to the object type `dyn std::future::Future&lt;Output = ()&gt; + std::marker::Send`
  
  safebrowsing.rs(22, 19): future is not `Send` as this value is used across an await
                 ^-- match reqwest::get(&quot;url&quot;).await
  </code></pre>
  <p>I already tried to implement the <strong>Send</strong>-Trait to my Safebrowsing-Struct, but that does also not work.
  Is there something I need to do to get it working? Because I have no clue why that is appearing</p>