rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Vincenzo Palazzo" <vincenzopalazzodev@gmail.com>,
	"Will Deacon" <will@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Sergio González Collado" <sergio.collado@gmail.com>,
	"Finn Behrens" <fin@nyantec.com>
Subject: Re: [PATCH v2 2/2] sample: rust: print: Add sampe code for Arc printing
Date: Wed, 8 Feb 2023 16:19:04 +0100	[thread overview]
Message-ID: <CANiq72kyrz4efU5=MexgGNth1XxkU1z-GP6xVa7WxApB+PMdFQ@mail.gmail.com> (raw)
In-Reply-To: <20230207185216.1314638-3-boqun.feng@gmail.com>

On Tue, Feb 7, 2023 at 7:52 PM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> +    // Uses `dbg` to print, will move `c`.
> +    dbg!(c);

Perhaps:

    // Uses `dbg` to print, will move `c` (for temporary debugging purposes).
    dbg!(c);

To make it clear it is not meant to be usually committed into the tree.

> +    // Prints debug fmt with pretty-print "#" and number-in-hex "x".
> +    pr_info!("{:#x?}", a);

Apparently, `:#x?` is a bit of an accident: `#` means "alternate"
form, but it turns out it applies to both `x` and `?`, i.e. it is not
that `#` alone implies pretty-printing.

Given the above and that there are improvements under discussion
upstream, perhaps we could avoid giving details for the moment and
just say what it does as a whole, e.g.

    // Pretty-prints the debug formatting with lower-case hexadecimal integers.
    pr_info!("{:#x?}", a);

Some links for those interested:
https://doc.rust-lang.org/std/fmt/index.html#sign0,
https://github.com/rust-lang/rust/issues/75766,
https://github.com/rust-lang/rust/pull/99138#issuecomment-1385331055
and https://github.com/rust-lang/libs-team/issues/165.

Finally, there is a small typo in the commit title. What about:

    rust: samples: print: add sample code for `Arc` printing

I can change these bits on my side if you want & agree with them, to
avoid a v3 just for this.

Thanks for these patches, Boqun!

Cheers,
Miguel

  parent reply	other threads:[~2023-02-08 15:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 18:52 [PATCH v2 0/2] rust: sync: Arc: Implement Debug and Display Boqun Feng
2023-02-07 18:52 ` [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc Boqun Feng
2023-02-07 19:03   ` Carlos Bilbao
2023-02-07 20:27     ` Vincenzo Palazzo
2023-02-07 20:45   ` Vincenzo Palazzo
2023-02-07 20:54     ` Boqun Feng
2023-02-08  4:57   ` Gary Guo
2023-02-08 10:00   ` Andreas Hindborg
2023-02-08 13:43   ` Björn Roy Baron
2023-02-07 18:52 ` [PATCH v2 2/2] sample: rust: print: Add sampe code for Arc printing Boqun Feng
2023-02-08  4:57   ` Gary Guo
2023-02-08 10:01   ` Andreas Hindborg
2023-02-08 15:19   ` Miguel Ojeda [this message]
2023-02-08 16:33     ` Boqun Feng
2023-02-08 16:56       ` Miguel Ojeda
2023-02-08 16:58         ` Boqun Feng
2023-04-10  2:53 ` [PATCH v2 0/2] rust: sync: Arc: Implement Debug and Display Miguel Ojeda

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='CANiq72kyrz4efU5=MexgGNth1XxkU1z-GP6xVa7WxApB+PMdFQ@mail.gmail.com' \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=alex.gaynor@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=fin@nyantec.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sergio.collado@gmail.com \
    --cc=vincenzopalazzodev@gmail.com \
    --cc=wedsonaf@gmail.com \
    --cc=will@kernel.org \
    /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).