Re: [PATCH net-next v2 1/6] rust: time: Implement PartialEq and PartialOrd for Ktime

From: Alice Ryhl
Date: Mon Oct 07 2024 - 04:42:53 EST


On Mon, Oct 7, 2024 at 7:37 AM FUJITA Tomonori
<fujita.tomonori@xxxxxxxxx> wrote:
>
> On Sun, 06 Oct 2024 12:28:59 +0200
> Fiona Behrens <finn@xxxxxxxxxx> wrote:
>
> >> Implement PartialEq and PartialOrd trait for Ktime by using C's
> >> ktime_compare function so two Ktime instances can be compared to
> >> determine whether a timeout is met or not.
> >
> > Why is this only PartialEq/PartialOrd? Could we either document why or implement Eq/Ord as well?
>
> Because what we need to do is comparing two Ktime instances so we
> don't need them?

When you implement PartialEq without Eq, you are telling the reader
that this is a weird type such as floats where there exists values
that are not equal to themselves. That's not the case here, so don't
confuse the reader by leaving out `Eq`.

Alice