title: How to test for equality between trait objects?
body: <blockquote>
    <p>Editor's note: This code example is from a version of Rust prior to 1.0 and is not syntactically valid Rust 1.0 code. Updated versions of this code produce different errors, but the answers still contain valuable information.</p>
  </blockquote>
  
  <p>It seems like we cannot test for equality in the following case. Why is this? Is there a workaround? (I am using Rust 0.11).</p>
  
  <pre><code>trait A: PartialEq {}
  
  #[deriving(PartialEq)]
  enum T {Ta, Tb}
  
  impl A for T {}
  
  fn main() {
    assert!(Ta == Ta);
    assert!(Ta != Tb);
    assert!(some_fn(&amp;Ta, &amp;Ta));
    assert!(!some_fn(&amp;Ta, &amp;Tb));
  }
  
  fn some_fn(an_a: &amp;A, another_a: &amp;A) -&gt; bool {
      an_a == another_a
  // ERROR ^~~~~~~~~~~~ binary operation `==` cannot be applied to type `&amp;A`
  }
  
  fn another_fn(an_a: &amp;A + PartialEq, another_a: &amp;A + PartialEq) -&gt; bool {
                 // ERROR: ^~~~~~~~~ only the builtin traits can be used as closure or object bounds
      an_a == another_a
  }
  </code></pre>