Need to compare custom TupleStruct directly with type equals to type into this struct

I have this TupleStruct:

struct PackedGuid(u64);

and I want to make it possible to compare with u64 directly without unpack:

// currently my code works like below
let guid1: u64 = 0;
let PackedGuid(guid) = some_packed_guid;
if guid == guid1 {
    // ...
}

// but I want smth like this:
let guid1: u64 = 0;
let packed_guid = PackedGuid(0);
if packed_guid == guid1 {
    // ...
}
// or like this:
if guid1 == packed_guid {
    // ...
}

Could somebody explain does it exist any trait or approach for such case ?

You can implement PartialEq<u64> for your PackedGuid type

1 Like

Thank you !

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.