[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251117132147.07424ca6@nimda.home>
Date: Mon, 17 Nov 2025 13:21:47 +0300
From: Onur Özkan <work@...rozkan.dev>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Lyude Paul <lyude@...hat.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org, Andreas Hindborg <a.hindborg@...nel.org>,
Boqun Feng <boqun.feng@...il.com>, FUJITA Tomonori
<fujita.tomonori@...il.com>, Frederic Weisbecker <frederic@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Anna-Maria Behnsen
<anna-maria@...utronix.de>, John Stultz <jstultz@...gle.com>, Stephen Boyd
<sboyd@...nel.org>, Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor
<alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>, Björn
Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, Danilo
Krummrich <dakr@...nel.org>
Subject: Re: [PATCH] rust/time: Add Delta::from_nanos()
On Sun, 16 Nov 2025 12:06:41 +0100
Miguel Ojeda <miguel.ojeda.sandonis@...il.com> wrote:
> On Sun, Nov 16, 2025 at 7:38 AM Onur Özkan <work@...rozkan.dev> wrote:
> >
> > I wonder if it makes sense to remove all the `from_*` functions from
> > `Delta` and replace them all with something like this:
> >
> > pub const fn from_duration(duration: Duration) -> Self {
> > Self {
> > nanos: duration.as_nanos(),
> > }
> > }
> >
> > What do you think?
>
> `Delta`s can be negative and only store the nanos -- i.e. there are
> many `Duration`s that do not fit in a `Delta` (`as_nanos()` above
> returns `u128`).
>
I didn't know, thanks :)
> `Delta`s are similar to `Duration` in the sense that they both store a
> span of time. It seems reasonable to support similar constructors,
> since they perform similar roles and we may not use `Duration`s.
>
> Now, I agree that other types should not start getting things like
> nano parameters or `from_nanos` constructors -- they should take
> `Delta`s instead.
>
Yes, that seems like a good and simple improvement.
Regards,
Onur
> Cheers,
> Miguel
Powered by blists - more mailing lists