4 ms·
It is determined at compile time; I'm not sure why GP is suggesting returning false if you don't want types to be compared. By default structs are not comparabl
by re 7y ago
It is determined at compile time; I'm not sure why GP is suggesting returning false if you don't want types to be compared. By default structs are not comparable. If you opt-in to the standard PartialEq implementation using the `derive` annotation[1], it will only allow a struct to be compared for equality with other structs of the same type. You can choose to add implementations to compare against other types[2].
[1] https://doc.rust-lang.org/book/ch05-02-example-structs.html#adding-useful-functionality-with-derived-traits https://doc.rust-lang.org/book/ch05-02-example-structs.html#...
[2] https://doc.rust-lang.org/std/cmp/trait.PartialEq.html#how-can-i-compare-two-different-types https://doc.rust-lang.org/std/cmp/trait.PartialEq.html#how-c...
- artursapek 7y agoRust is such a delightful language.