lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiq72nueMj-4nmf=s44=AskbRFzHDQgmqfd12Jo89CMyySOnQ@mail.gmail.com>
Date: Sun, 16 Nov 2025 12:06:41 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Onur Özkan <work@...rozkan.dev>
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, 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`).

`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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ