Re: [PATCH v2 2/2] sample: rust: print: Add sampe code for Arc printing

From: Boqun Feng
Date: Wed Feb 08 2023 - 11:34:25 EST


On Wed, Feb 08, 2023 at 04:19:04PM +0100, Miguel Ojeda wrote:
> On Tue, Feb 7, 2023 at 7:52 PM Boqun Feng <boqun.feng@xxxxxxxxx> 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.
>

Thanks!

> > + // 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.
>

Oh, good to know!

> 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
>

Hmm.. I'm OK with this change, but it's not a typo ;-)

I deliberately

1) capitalize the first letter after subsystem tags in the title
since that's kinda the rule for a few subsystems I usually work
on, I don't have my own preference, just something I'm used to
;-)

2) avoid using "`" in the title to save space because title space
is precious.

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

That'll be great, thanks!

Regards,
Boqun

> Thanks for these patches, Boqun!
>
> Cheers,
> Miguel