title: expected trait object `dyn Responsability`, found type parameter `T`
body: <p>I am trying to implement a responsability chain in Rust:</p>
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=941081e963ff2c6e16bea80ca1fd5086" rel="nofollow noreferrer">link to playground</a></p>
  <pre class="lang-rust prettyprint-override"><code>use std::error::Error;
  
  struct Query {
      query: String,
  }
  
  struct Response {
      response: u64,
  }
  
  trait Responsability {
      fn take(&amp;self, iterator: std::slice::Iter&lt;Box&lt;dyn Responsability&gt;&gt;, query: Query) -&gt; Result&lt;Response, Box&lt;dyn Error&gt;&gt;;
  }
  
  struct ResponsabilityChain&lt;T: Responsability&gt; {
      responsabilities: Vec&lt;Box&lt;T&gt;&gt;,
  }
  
  impl&lt;T: Responsability&gt; ResponsabilityChain&lt;T&gt;
  where
      T: Responsability,
  {
      pub fn new(responsabilities: Vec&lt;T&gt;) -&gt; Self {
          let responsabilities = responsabilities.into_iter()
              .map(|elt| Box::new(elt))
              .collect();
          
          Self { responsabilities }
      }
      
      pub fn launch(&amp;self, query: Query) -&gt; Result&lt;Response, Box&lt;dyn Error&gt;&gt; {
          let iterator = self.responsabilities.iter();
          let responsability = iterator.next().unwrap();
          
          responsability.take(iterator, query)
      }
  }
  
  fn main() {
      println!(&quot;Hello, world!&quot;);
  }
  </code></pre>
  <p>The infamous message is:</p>
  <blockquote>
  <p>Compiling playground v0.0.1 (/playground) error[E0308]: mismatched
  types   --&gt; src/main.rs:35:29    | 19 | impl&lt;T: Responsability&gt;
  ResponsabilityChain    |      - this type parameter ... 35 |<br />
  responsability.take(iterator, query)    |<br />
  ^^^^^^^^ expected trait object <code>dyn Responsability</code>, found type
  parameter <code>T</code>    |    = note: expected struct <code>std::slice::Iter&lt;'_, Box&lt;(dyn Responsability + 'static)&gt;&gt;</code>
  found struct <code>std::slice::Iter&lt;'_, Box&lt;T&gt;&gt;</code>    = help: type parameters must be constrained to match other types    = note:
  for more information, visit
  <a href="https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters" rel="nofollow noreferrer">https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters</a></p>
  <p>For more information about this error, try <code>rustc --explain E0308</code>.
  error: could not compile <code>playground</code> due to previous error</p>
  </blockquote>
  <p>I do not understand why the compiler complains expecting <code>Box&lt;dyn Responsability&gt;</code> while having <code>Box&lt;T&gt;</code> since I specify <code>T: Responsability</code>. What do I do wrong?</p>