Re: [PATCH v2] rust: time: New module for timekeeping functions

From: Miguel Ojeda
Date: Sat Jul 15 2023 - 12:59:45 EST


On Fri, Jul 14, 2023 at 12:05 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> In that case, you should explicitly use `.wrapping_sub` instead to
> convey your intent.

Also to prevent extra code and panics with `CONFIG_RUST_OVERFLOW_CHECKS=y`.

> I guess you could also use `abs_diff`, which takes two i64s and returns
> an u64.

I think `abs_diff` sounds best. It introduces an extra branch in its
implementation from what I see, though...

However, since it is the same branch that Lina does for returning
`None`, it should be getting removed. At least in a quick test, LLVM
generates the same code: https://godbolt.org/z/61rafzx71

Cheers,
Miguel