|
|
|
|
|
by jeffadotio
2299 days ago
|
|
I really like this about Rust, implementing equality is just another trait. The same is true of comparison operators. If you don’t want a type to be able to be compared by == you can make it always evaluate to false or even panic and give a message that the type cannot be used in that way. That might aggravate coders who do not test comprehensively but it is an option. Edit: This is a response to the concerns of the article. For general info on this it’s a great introduction to Rust’s awesome documentation. https://doc.rust-lang.org/std/cmp/trait.Eq.html |
|