title: Checking equality of custom structs
body: <p>I'm trying to check equality of two (functionally identical) structs.</p>
  
  <pre><code>#[derive(PartialEq, Debug)]
  pub struct TypeA&lt;'a&gt;(&amp;'a str);
  
  #[derive(PartialEq, Debug)]
  pub struct TypeB&lt;'a&gt;(&amp;'a str);
  
  impl&lt;'a&gt; TypeA&lt;'a&gt; {
      pub fn new(n: &amp;str) -&gt; TypeA {
          TypeA(n)
      }
  }
  
  impl&lt;'a&gt; TypeB&lt;'a&gt; {
      pub fn new(n: &amp;str) -&gt; TypeB {
          TypeB(n)
      }
  }
  
  fn main() {
      assert_eq!(TypeA::new("A"), TypeB::new("A"));
  }
  </code></pre>
  
  <p>It returns the error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
    --&gt; src/main.rs:20:5
     |
  20 |     assert_eq!(TypeA::new("A"), TypeB::new("A"));
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `TypeA`, found struct `TypeB`
     |
     = note: expected type `TypeA&lt;'_&gt;`
                found type `TypeB&lt;'_&gt;`
     = note: this error originates in a macro outside of the current crate
  </code></pre>
  
  <p>It seems like deriving <code>PartialEq</code> isn't working. Is the only solution to implement it manually between these two types? Is the problem somewhere else entirely?</p>