title: How do implement a struct that takes a trait MyTrait<A>?
body: <p>I've defined a trait as follows:</p>
  <pre class="lang-rust prettyprint-override"><code>trait Readable&lt;E&gt; {
      fn read_u8(&amp;mut self) -&gt; Result&lt;u8, E&gt;;
      fn read_u16be(&amp;mut self) -&gt; Result&lt;u16, E&gt;;
  }
  </code></pre>
  <p>The idea is to implement it with different backends returning different error types. I tried to use it in a function:</p>
  <pre class="lang-rust prettyprint-override"><code>fn f&lt;E, R: Readable&lt;E&gt;&gt;(r: &amp;mut R) -&gt; Result&lt;u8, E&gt; {
      r.read_u8()
  }
  </code></pre>
  <p>This compiles. I tried the same in an impl:</p>
  <pre class="lang-rust prettyprint-override"><code>struct FileFormat&lt;R&gt; {
      r: R,
  }
  
  impl&lt;E, R: Readable&lt;E&gt;&gt; FileFormat&lt;R&gt; {
      fn f(&amp;mut self) -&gt; Result&lt;u8, E&gt; {
          self.r.read_u8()
      }
  }
  </code></pre>
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=15bdbd4d7445a3a5d067ef4e4665e237" rel="nofollow noreferrer">Playground</a></p>
  <p>This fails with:</p>
  <pre class="lang-none prettyprint-override"><code>14 | impl&lt;E, R: Readable&lt;E&gt;&gt; FileFormat&lt;R&gt; {
     |      ^ unconstrained type parameter
  </code></pre>
  <p>The compiler suggests <code>rustc --explain E0207</code> but I'm afraid I haven't been able to understand the answer contained within if it's there.</p>
  <p>Why does the former compile while the latter doesn't? Why is <code>E</code> in this case is unconstrained? How to resolve this so that the implementation will be able to take any <code>Readable</code>?</p>