Messages in this thread | | | From | Miguel Ojeda <> | Date | Sat, 15 Jul 2023 18:59:10 +0200 | Subject | Re: [PATCH v2] rust: time: New module for timekeeping functions |
| |
On Fri, Jul 14, 2023 at 12:05 PM Alice Ryhl <aliceryhl@google.com> 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
| |