From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: "Onur Özkan" <work@onurozkan.dev>
Cc: "Lyude Paul" <lyude@redhat.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"John Stultz" <jstultz@google.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>
Subject: Re: [PATCH] rust/time: Add Delta::from_nanos()
Date: Sun, 16 Nov 2025 12:06:41 +0100 [thread overview]
Message-ID: <CANiq72nueMj-4nmf=s44=AskbRFzHDQgmqfd12Jo89CMyySOnQ@mail.gmail.com> (raw)
In-Reply-To: <20251116093805.7918b83d@nimda.home>
On Sun, Nov 16, 2025 at 7:38 AM Onur Özkan <work@onurozkan.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`).
`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.
Cheers,
Miguel
next prev parent reply other threads:[~2025-11-16 11:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 18:42 [PATCH] rust/time: Add Delta::from_nanos() Lyude Paul
2025-11-16 6:38 ` Onur Özkan
2025-11-16 11:06 ` Miguel Ojeda [this message]
2025-11-17 10:21 ` Onur Özkan
2025-11-17 1:39 ` FUJITA Tomonori
2025-11-17 11:15 ` Andreas Hindborg
2025-11-17 11:38 ` FUJITA Tomonori
2025-11-17 12:26 ` Andreas Hindborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANiq72nueMj-4nmf=s44=AskbRFzHDQgmqfd12Jo89CMyySOnQ@mail.gmail.com' \
--to=miguel.ojeda.sandonis@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=anna-maria@linutronix.de \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).