More generic #[derive(PartialEq)]?

#[derive(PartialEq)]
struct Container<B>(B);

fn cmp(v1: Container<&[u8]>, v2: Container<Vec<u8>>) -> bool {
    v1 == v2
}
error[E0308]: mismatched types
 --> src/lib.rs:5:11
  |
5 |     v1 == v2
  |           ^^ expected `Container<&[u8]>`, found `Container<Vec<u8>>`
  |
  = note: expected struct `Container<&[u8]>`
             found struct `Container<Vec<u8>>`

playground

There is impl<'a> PartialEq<Vec<u8>> for &'a [u8] so I think it won't fail.

Also how can I manually impl this if Container is a complex enum like serde_json::Value and some variants contain the generic B?

This is a question which would be better posted on users.rust-lang.org.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.