Newbie misread Eq Trait

⚓ Rust    📅 2026-01-31    👤 surdeus    👁️ 11      

surdeus

Warning

This post was published 31 days ago. The information described in this article may have changed.

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Newbie misread Eq Trait

I am apparently misreading what the Eq trait does when I declare it to be derived on a struct. What I am trying to achieve is that an instance of the struct is equal to itself, but not equal to another instance even if all the fields are identical. I got that PartialEq would not do that. But when I tried adding Eq, it was still trying to apply it to the intdividual fields. Wo what is Eq trying to do? And how to do I get the goal I am after?
Thanks,
Joel

4 posts - 3 participants

Read full topic

🏷️ Rust_feed