title: Implement a trait for all types implementing a trait
body: <p>I have this issue:</p>
  
  <ul>
  <li>multiple structs implementing a trait <code>Event</code></li>
  <li>all can implement <code>PartialEq</code> trait the same way</li>
  </ul>
  
  <p>I considered writing this (short version)</p>
  
  <pre class="lang-rust prettyprint-override"><code>type Data = Vec&lt;u8&gt;;
  
  trait Event {
      fn data(&amp;self) -&gt; &amp;Data;
  }
  
  struct NoteOn {
      data: Data,
  }
  struct NoteOff {
      data: Data,
  }
  impl Event for NoteOn {
      fn data(&amp;self) -&gt; &amp;Data {
          &amp;self.data
      }
  }
  impl Event for NoteOff {
      fn data(&amp;self) -&gt; &amp;Data {
          &amp;self.data
      }
  }
  impl&lt;T: Event&gt; PartialEq for T {
      fn eq(&amp;self, b: &amp;T) -&gt; bool {
          self.data() == b.data()
      }
  }
  
  fn main() {
      println!("Hello, world!");
  }
  </code></pre>
  
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=181a167f38dd84f83d20466e5fae5790" rel="nofollow noreferrer">playground</a></p>
  
  <p>This fails to compile:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0119]: conflicting implementations of trait `std::cmp::PartialEq&lt;&amp;_&gt;` for type `&amp;_`:
    --&gt; src/main.rs:23:1
     |
  23 | impl&lt;T: Event&gt; PartialEq for T {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: conflicting implementation in crate `core`:
             - impl&lt;A, B&gt; std::cmp::PartialEq&lt;&amp;B&gt; for &amp;A
               where A: std::cmp::PartialEq&lt;B&gt;, A: ?Sized, B: ?Sized;
     = note: downstream crates may implement trait `Event` for type `&amp;_`
  
  error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct&lt;T&gt;`)
    --&gt; src/main.rs:23:1
     |
  23 | impl&lt;T: Event&gt; PartialEq for T {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
     |
     = note: only traits defined in the current crate can be implemented for a type parameter
  </code></pre>
  
  <p>What is wrong here?
  Or is there another way to implement generically this <code>PartialEq</code> without having to type it once for <code>NoteOn</code> and once for <code>Noteff</code>?</p>
  
  <p>thank you</p>