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

From: Miguel Ojeda
Date: Wed Feb 22 2023 - 07:30:03 EST


On Wed, Feb 22, 2023 at 5:46 AM Asahi Lina <lina@xxxxxxxxxxxxx> wrote:
>
> For the actual Instant type, I was thinking it makes sense to just
> internally represent it as a newtype of Duration as well. Then all the
> math becomes trivial based on Duration operations, and when we replace
> Duration with a new u64 type it'll all work out the same. Fundamentally
> that means Instant types are internally stored as the Duration between
> the epoch (e.g. system boot) subject to the way that clock ticks, which
> I think is a reasonable internal representation?

Yeah, I think that is the way to go -- that is also how C++ represents
time points as well (including libstdc++, libc++ and STL from a quick
look), as well as Abseil too.

Cheers,
Miguel