Rust for Linux List
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"Lyude Paul" <lyude@redhat.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	"John Stultz" <jstultz@google.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: time: implement `Display` for `Delta`
Date: Mon, 11 May 2026 16:22:49 +0200	[thread overview]
Message-ID: <87ecji58li.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <aZLWjBWaBz4h4_SB@google.com>

Alice Ryhl <aliceryhl@google.com> writes:

> On Sun, Feb 15, 2026 at 09:14:05PM +0100, Andreas Hindborg wrote:
>> Implement the `Display` trait for `Delta` so that it can be displayed by a
>> formatter.
>> 
>> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>> ---
>>  rust/kernel/time.rs | 6 ++++++
>>  1 file changed, 6 insertions(+)
>> 
>> diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs
>> index 6ea98dfcd0278..e18fd17f38c5a 100644
>> --- a/rust/kernel/time.rs
>> +++ b/rust/kernel/time.rs
>> @@ -474,3 +474,9 @@ pub fn rem_nanos(self, dividend: i32) -> Self {
>>          }
>>      }
>>  }
>> +
>> +impl kernel::fmt::Display for Delta {
>> +    fn fmt(&self, f: &mut kernel::fmt::Formatter<'_>) -> kernel::fmt::Result {
>> +        f.write_fmt(kernel::prelude::fmt!("{}", self.as_nanos()))
>
> I think this can just be
>
> 	self.as_nanos().fmt(f)
>
> Though I think it would be nicer to include an 'ns' suffix here so it's
> not just the number?

I was planning to use this to format a delta to output via a configfs in
rnull. The existing C driver does not include the "ns" suffix, which is
why I did not either.

I am not opposed to adding the suffix for this particular
implementation, but that would mean my user for this code will no longer
be a user, and I would drop the patch in favor of another solution at
the call site.

Please advise which of the following make most sense:

 - Merge this patch without a suffix.
 - Iterate on this patch and merge it without a user.
 - Drop this patch for now.


Best regards,
Andreas Hindborg


  reply	other threads:[~2026-05-11 14:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15 20:14 [PATCH] rust: time: implement `Display` for `Delta` Andreas Hindborg
2026-02-16  8:34 ` Alice Ryhl
2026-05-11 14:22   ` Andreas Hindborg [this message]
2026-05-11 14:34     ` Gary Guo

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=87ecji58li.fsf@t14s.mail-host-address-is-not-set \
    --to=a.hindborg@kernel.org \
    --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@kernel.org \
    --cc=tmgross@umich.edu \
    /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