title: Trait's type member requires to be Send
body: <p>I have two traits: <code>Processor</code> and <code>Persist</code>. The first one is responsible for processing some entity, the second one is for <em><strong>asynchronous</strong></em> persisting the processed entity.</p>
  <p>Given the two traits I want to implement the <code>trait ProcessPersist</code> taking care of both processing and persisting. Here is how it looks like and <em><strong>compiles fine</strong></em></p>
  <pre><code>use async_trait::*;
  
  trait Processor&lt;T&gt;{
      type Output: Send;  // &lt;----------------------- Note Send here
  
      fn process(&amp;self, t: T) -&gt; Self::Output;
  }
  
  #[async_trait]
  trait Persist&lt;T&gt;{
      async fn persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt;;
  }
  
  #[async_trait]
  trait ProcessPersist&lt;T&gt;{
      async fn process_persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt;;
  }
  
  #[async_trait]
  impl&lt;T, M&gt; ProcessPersist&lt;T&gt; for M
  where
      T: Send + 'static,
      M: Processor&lt;T&gt; + Send + Sync,
      M: Persist&lt;&lt;M as Processor&lt;T&gt;&gt;::Output&gt;
  {
      async fn process_persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt; {
          let out = self.process(t);
          self.persist(out).await
      }
  }
  </code></pre>
  <p><strong>PROBLEM:</strong> The thing that I'm trying to avoid is to remove the context bound <code>type Output: Send</code> because this looks too restrictive. Instead, I'd like it to be specified in the <code>trait ProcessPersist</code> implementation somehow.</p>
  <p>Is it possible to do?</p>
  <p>Simply removing <code>Send</code> from the type <code>Output</code> <em><strong>does not compile</strong></em>:</p>
  <pre><code>use async_trait::*;
  
  trait Processor&lt;T&gt;{
      type Output;  // &lt;----------------------- Send is removed
  
      fn process(&amp;self, t: T) -&gt; Self::Output;
  }
  
  #[async_trait]
  trait Persist&lt;T&gt;{
      async fn persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt;;
  }
  
  #[async_trait]
  trait ProcessPersist&lt;T&gt;{
      async fn process_persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt;;
  }
  
  #[async_trait]
  impl&lt;T, M&gt; ProcessPersist&lt;T&gt; for M
  where
      T: Send + 'static,
      M: Processor&lt;T&gt; + Send + Sync,
      M: Persist&lt;&lt;M as Processor&lt;T&gt;&gt;::Output&gt;
  {
      async fn process_persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt; {
          let out = self.process(t);
          self.persist(out).await
      }
  }
  </code></pre>
  <p>Error message:</p>
  <pre><code>error: future cannot be sent between threads safely
    --&gt; src/main.rs:47:61
     |
  47 |       async fn process_persist(&amp;self, t: T) -&gt; Result&lt;(), ()&gt; {
     |  _____________________________________________________________^
  48 | |         let out = self.process(t);
  49 | |         self.persist(out).await
  50 | |     }
     | |_____^ future returned by `__process_persist` is not `Send`
     |
     = help: within `impl core::future::future::Future`, the trait `std::marker::Send` is not implemented for `&lt;M as Processor&lt;T&gt;&gt;::Output`
  note: future is not `Send` as this value is used across an await
    --&gt; src/main.rs:49:9
     |
  48 |         let out = self.process(t);
     |             --- has type `&lt;M as Processor&lt;T&gt;&gt;::Output` which is not `Send`
  49 |         self.persist(out).await
     |         ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here, with `out` maybe used later
  50 |     }
     |     - `out` is later dropped here
     = note: required for the cast to the object type `dyn core::future::future::Future&lt;Output = std::result::Result&lt;(), ()&gt;&gt; + std::marker::Send`
  </code></pre>