Re: [PATCH v2] rust: time: implement `Display` for `Delta`
From: Andreas Hindborg
Date: Wed Nov 04 2026 - 05:13:21 EST
"FUJITA Tomonori" <tomo@xxxxxxxxxxxx> writes:
> On Tue, 03 Nov 2026 16:23:40 +0100
> Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>
>> Implement the `Display` trait for `Delta` so that it can be displayed by a
>> formatter.
>
> [...]
>
>> - Drop the `rnull` user, which will call `Delta::as_nanos` instead (Gary).
>
> Now that the rnull user has been dropped, I wonder if we need this
> now.
>
> If we want a readable format with a unit, Debug might be a better fit.
> core::time::Duration implements only Debug, not Display, and its Debug
> output includes the unit (e.g. 1.5s). Debug output is not expected to
> be stable, so we could change the format later. Users that need a
> fixed format can use as_nanos(), like rnull does.
>
> What do you think?
I think consensus on v1 was that a `Display` implementation would be
good to have even though no user, which is why I decided to send this
again.
I do think it is nice to have, but maybe we should consider doing some
kind of intelligent selection of the unit with rounding?
We can also change it to be a `Debug` implementation. I was not aware
about the stability requirement. But I guess that is mostly a user space
thing? In the kernel we can change stuff as we see fit, as long as we do
not interfere with the uapi.
Best regards,
Andreas Hindborg