lkml.org 
[lkml]   [2023]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 2/2] sample: rust: print: Add sampe code for Arc printing
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

\
 
 \ /
  Last update: 2023-03-27 00:15    [W:0.129 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site