Closed PPakalns closed 7 months ago
This is a nice convenience, but there is a correctness issue with it. PartialEq
guarantees transitivity, which may not hold, depending on the implementation for T
. For example:
#[derive(Soars)]
struct Example(u8);
impl PartialEq for Example {
fn eq(&self, other: &Self) -> bool {
true
}
}
fn main() {
assert_eq!(Example(0), Example(1)); // okay
assert_eq!(Example(1), ExampleRef(1)); // okay
assert_eq!(Example(0), ExampleRef(1)); // panic
}
This project has taught me there are a lot of subtleties like this to be wary of in Rust.
Allow Soars derive macro to be used with types that do not implement PartialEq for all fields