2023-02-07 18:52:53

by Boqun Feng

[permalink] [raw]
Subject: [PATCH v2 0/2] rust: sync: Arc: Implement Debug and Display

previous version:

v1: https://lore.kernel.org/rust-for-linux/[email protected]/

Changes since v1:

* Remove the refcount for Debug impl as per Peter and Greg.
* Since the refcount_read() bits are removed, therefore squash all
4 patches into one (I keep the Reviewed-by tags for anyone that
gave to both patch #1 and patch #4 in v1). Thanks for everyone
for the reviewing ;-)


I found that our Arc doesn't implement `Debug` or `Display` when I tried
to play with them, therefore add these implementation.

With these changes, I could get the following print with the sample code
in patch #2:

[..] rust_print: 1
[..] rust_print: "hello, world"
[..] rust_print: [samples/rust/rust_print.rs:34] c = "hello, world"
[..] rust_print: "hello, world"

Suggestions and comments are welcome!

Regards,
Boqun

--
2.39.1



2023-02-07 18:52:55

by Boqun Feng

[permalink] [raw]
Subject: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

This allows printing the inner data of `Arc` and its friends if the
inner data implements `Display` or `Debug`. It's useful for logging and
debugging purpose.

Signed-off-by: Boqun Feng <[email protected]>
Reviwed-by: Vincenzo Palazzo <[email protected]>
---
rust/kernel/sync/arc.rs | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index 519a6ec43644..e6176d9b5b29 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -22,6 +22,7 @@ use crate::{
};
use alloc::boxed::Box;
use core::{
+ fmt,
marker::{PhantomData, Unsize},
mem::{ManuallyDrop, MaybeUninit},
ops::{Deref, DerefMut},
@@ -522,3 +523,27 @@ impl<T: ?Sized> DerefMut for UniqueArc<T> {
unsafe { &mut self.inner.ptr.as_mut().data }
}
}
+
+impl<T: fmt::Display + ?Sized> fmt::Display for UniqueArc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt::Display::fmt(self.deref(), f)
+ }
+}
+
+impl<T: fmt::Display + ?Sized> fmt::Display for Arc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt::Display::fmt(self.deref(), f)
+ }
+}
+
+impl<T: fmt::Debug + ?Sized> fmt::Debug for UniqueArc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt::Debug::fmt(self.deref(), f)
+ }
+}
+
+impl<T: fmt::Debug + ?Sized> fmt::Debug for Arc<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt::Debug::fmt(self.deref(), f)
+ }
+}
--
2.39.1


2023-02-07 18:52:59

by Boqun Feng

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

This both demonstrates the usage of different print format in Rust and
serves as a selftest for the `Display` and `Debug` implementation of
`Arc` and its friends.

Signed-off-by: Boqun Feng <[email protected]>
Reviewed-by: Björn Roy Baron <[email protected]>
Reviewed-by: Finn Behrens <[email protected]>
Reviewed-by: Vincenzo Palazzo <[email protected]>
---
samples/rust/rust_print.rs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/samples/rust/rust_print.rs b/samples/rust/rust_print.rs
index 8b39d9cef6d1..165a8d7b1c07 100644
--- a/samples/rust/rust_print.rs
+++ b/samples/rust/rust_print.rs
@@ -15,6 +15,30 @@ module! {

struct RustPrint;

+fn arc_print() -> Result {
+ use kernel::sync::*;
+
+ let a = Arc::try_new(1)?;
+ let b = UniqueArc::try_new("hello, world")?;
+
+ // Prints the value of data in `a`.
+ pr_info!("{}", a);
+
+ // Uses ":?" to print debug fmt of `b`.
+ pr_info!("{:?}", b);
+
+ let a: Arc<&str> = b.into();
+ let c = a.clone();
+
+ // Uses `dbg` to print, will move `c`.
+ dbg!(c);
+
+ // Prints debug fmt with pretty-print "#" and number-in-hex "x".
+ pr_info!("{:#x?}", a);
+
+ Ok(())
+}
+
impl kernel::Module for RustPrint {
fn init(_module: &'static ThisModule) -> Result<Self> {
pr_info!("Rust printing macros sample (init)\n");
@@ -43,6 +67,8 @@ impl kernel::Module for RustPrint {
pr_cont!(" is {}", "continued");
pr_cont!(" with {}\n", "args");

+ arc_print()?;
+
Ok(RustPrint)
}
}
--
2.39.1


2023-02-07 19:04:31

by Bilbao, Carlos

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

On 2/7/23 12:52, Boqun Feng wrote:

> This allows printing the inner data of `Arc` and its friends if the
> inner data implements `Display` or `Debug`. It's useful for logging and
> debugging purpose.
>
> Signed-off-by: Boqun Feng <[email protected]>
> Reviwed-by: Vincenzo Palazzo <[email protected]>


s/Reviwed/Reviewed


> ---
> rust/kernel/sync/arc.rs | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 519a6ec43644..e6176d9b5b29 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -22,6 +22,7 @@ use crate::{
> };
> use alloc::boxed::Box;
> use core::{
> + fmt,
> marker::{PhantomData, Unsize},
> mem::{ManuallyDrop, MaybeUninit},
> ops::{Deref, DerefMut},
> @@ -522,3 +523,27 @@ impl<T: ?Sized> DerefMut for UniqueArc<T> {
> unsafe { &mut self.inner.ptr.as_mut().data }
> }
> }
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}


Just a thought, perhaps it's worth creating a macro to implement this
trait, since all do the same with fmt and others might join later on.


Thanks,
Carlos

2023-02-07 20:27:46

by Vincenzo Palazzo

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

On Tue Feb 7, 2023 at 7:03 PM UTC, Carlos Bilbao wrote:
> On 2/7/23 12:52, Boqun Feng wrote:
>
> > This allows printing the inner data of `Arc` and its friends if the
> > inner data implements `Display` or `Debug`. It's useful for logging and
> > debugging purpose.
> >
> > Signed-off-by: Boqun Feng <[email protected]>
> > Reviwed-by: Vincenzo Palazzo <[email protected]>
>
>
> s/Reviwed/Reviewed
Ops! this is my fautl! I will review the version 2.

2023-02-07 20:46:07

by Vincenzo Palazzo

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

> This allows printing the inner data of `Arc` and its friends if the
> inner data implements `Display` or `Debug`. It's useful for logging and
> debugging purpose.
>
> Signed-off-by: Boqun Feng <[email protected]>
> Reviwed-by: Vincenzo Palazzo <[email protected]>
> ---
With this review I will override my previous one, because it
contains a typo inside the Reviewed-by.

Sorry about that!

Reviewed-by: Vincenzo Palazzo <[email protected]>

2023-02-07 20:55:40

by Boqun Feng

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

On Tue, Feb 07, 2023 at 08:45:59PM +0000, Vincenzo Palazzo wrote:
> > This allows printing the inner data of `Arc` and its friends if the
> > inner data implements `Display` or `Debug`. It's useful for logging and
> > debugging purpose.
> >
> > Signed-off-by: Boqun Feng <[email protected]>
> > Reviwed-by: Vincenzo Palazzo <[email protected]>
> > ---
> With this review I will override my previous one, because it
> contains a typo inside the Reviewed-by.
>
> Sorry about that!
>

No worries.

> Reviewed-by: Vincenzo Palazzo <[email protected]>

Thanks!

Regards,
Boqun

2023-02-08 04:57:54

by Gary Guo

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

On Tue, 7 Feb 2023 10:52:15 -0800
Boqun Feng <[email protected]> wrote:

> This allows printing the inner data of `Arc` and its friends if the
> inner data implements `Display` or `Debug`. It's useful for logging and
> debugging purpose.
>
> Signed-off-by: Boqun Feng <[email protected]>
> Reviwed-by: Vincenzo Palazzo <[email protected]>

Reviewed-by: Gary Guo <[email protected]>

> ---
> rust/kernel/sync/arc.rs | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 519a6ec43644..e6176d9b5b29 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -22,6 +22,7 @@ use crate::{
> };
> use alloc::boxed::Box;
> use core::{
> + fmt,
> marker::{PhantomData, Unsize},
> mem::{ManuallyDrop, MaybeUninit},
> ops::{Deref, DerefMut},
> @@ -522,3 +523,27 @@ impl<T: ?Sized> DerefMut for UniqueArc<T> {
> unsafe { &mut self.inner.ptr.as_mut().data }
> }
> }
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}


2023-02-08 04:58:05

by Gary Guo

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

On Tue, 7 Feb 2023 10:52:16 -0800
Boqun Feng <[email protected]> wrote:

> This both demonstrates the usage of different print format in Rust and
> serves as a selftest for the `Display` and `Debug` implementation of
> `Arc` and its friends.
>
> Signed-off-by: Boqun Feng <[email protected]>
> Reviewed-by: Björn Roy Baron <[email protected]>
> Reviewed-by: Finn Behrens <[email protected]>
> Reviewed-by: Vincenzo Palazzo <[email protected]>

Reviewed-by: Gary Guo <[email protected]>

> ---
> samples/rust/rust_print.rs | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/samples/rust/rust_print.rs b/samples/rust/rust_print.rs
> index 8b39d9cef6d1..165a8d7b1c07 100644
> --- a/samples/rust/rust_print.rs
> +++ b/samples/rust/rust_print.rs
> @@ -15,6 +15,30 @@ module! {
>
> struct RustPrint;
>
> +fn arc_print() -> Result {
> + use kernel::sync::*;
> +
> + let a = Arc::try_new(1)?;
> + let b = UniqueArc::try_new("hello, world")?;
> +
> + // Prints the value of data in `a`.
> + pr_info!("{}", a);
> +
> + // Uses ":?" to print debug fmt of `b`.
> + pr_info!("{:?}", b);
> +
> + let a: Arc<&str> = b.into();
> + let c = a.clone();
> +
> + // Uses `dbg` to print, will move `c`.
> + dbg!(c);
> +
> + // Prints debug fmt with pretty-print "#" and number-in-hex "x".
> + pr_info!("{:#x?}", a);
> +
> + Ok(())
> +}
> +
> impl kernel::Module for RustPrint {
> fn init(_module: &'static ThisModule) -> Result<Self> {
> pr_info!("Rust printing macros sample (init)\n");
> @@ -43,6 +67,8 @@ impl kernel::Module for RustPrint {
> pr_cont!(" is {}", "continued");
> pr_cont!(" with {}\n", "args");
>
> + arc_print()?;
> +
> Ok(RustPrint)
> }
> }


2023-02-08 10:01:46

by Andreas Hindborg

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc


Boqun Feng <[email protected]> writes:

> This allows printing the inner data of `Arc` and its friends if the
> inner data implements `Display` or `Debug`. It's useful for logging and
> debugging purpose.
>
> Signed-off-by: Boqun Feng <[email protected]>
> Reviwed-by: Vincenzo Palazzo <[email protected]>
> ---

Reviewed-by: Andreas Hindborg <[email protected]>

> rust/kernel/sync/arc.rs | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 519a6ec43644..e6176d9b5b29 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -22,6 +22,7 @@ use crate::{
> };
> use alloc::boxed::Box;
> use core::{
> + fmt,
> marker::{PhantomData, Unsize},
> mem::{ManuallyDrop, MaybeUninit},
> ops::{Deref, DerefMut},
> @@ -522,3 +523,27 @@ impl<T: ?Sized> DerefMut for UniqueArc<T> {
> unsafe { &mut self.inner.ptr.as_mut().data }
> }
> }
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}


2023-02-08 10:02:20

by Andreas Hindborg

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


Boqun Feng <[email protected]> writes:

> This both demonstrates the usage of different print format in Rust and
> serves as a selftest for the `Display` and `Debug` implementation of
> `Arc` and its friends.
>
> Signed-off-by: Boqun Feng <[email protected]>
> Reviewed-by: Björn Roy Baron <[email protected]>
> Reviewed-by: Finn Behrens <[email protected]>
> Reviewed-by: Vincenzo Palazzo <[email protected]>
> ---

Reviewed-by: Andreas Hindborg <[email protected]>


> samples/rust/rust_print.rs | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/samples/rust/rust_print.rs b/samples/rust/rust_print.rs
> index 8b39d9cef6d1..165a8d7b1c07 100644
> --- a/samples/rust/rust_print.rs
> +++ b/samples/rust/rust_print.rs
> @@ -15,6 +15,30 @@ module! {
>
> struct RustPrint;
>
> +fn arc_print() -> Result {
> + use kernel::sync::*;
> +
> + let a = Arc::try_new(1)?;
> + let b = UniqueArc::try_new("hello, world")?;
> +
> + // Prints the value of data in `a`.
> + pr_info!("{}", a);
> +
> + // Uses ":?" to print debug fmt of `b`.
> + pr_info!("{:?}", b);
> +
> + let a: Arc<&str> = b.into();
> + let c = a.clone();
> +
> + // Uses `dbg` to print, will move `c`.
> + dbg!(c);
> +
> + // Prints debug fmt with pretty-print "#" and number-in-hex "x".
> + pr_info!("{:#x?}", a);
> +
> + Ok(())
> +}
> +
> impl kernel::Module for RustPrint {
> fn init(_module: &'static ThisModule) -> Result<Self> {
> pr_info!("Rust printing macros sample (init)\n");
> @@ -43,6 +67,8 @@ impl kernel::Module for RustPrint {
> pr_cont!(" is {}", "continued");
> pr_cont!(" with {}\n", "args");
>
> + arc_print()?;
> +
> Ok(RustPrint)
> }
> }


2023-02-08 13:44:33

by Björn Roy Baron

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] rust: sync: impl {Debug,Display} for {Unique,}Arc

On Tuesday, February 7th, 2023 at 19:52, Boqun Feng <[email protected]> wrote:

> This allows printing the inner data of `Arc` and its friends if the
> inner data implements `Display` or `Debug`. It's useful for logging and
> debugging purpose.
>
> Signed-off-by: Boqun Feng [email protected]
>
> Reviwed-by: Vincenzo Palazzo [email protected]

Reviewed-by: Björn Roy Baron <[email protected]>

>
> ---
> rust/kernel/sync/arc.rs | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 519a6ec43644..e6176d9b5b29 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -22,6 +22,7 @@ use crate::{
> };
> use alloc::boxed::Box;
> use core::{
> + fmt,
> marker::{PhantomData, Unsize},
> mem::{ManuallyDrop, MaybeUninit},
> ops::{Deref, DerefMut},
> @@ -522,3 +523,27 @@ impl<T: ?Sized> DerefMut for UniqueArc<T> {
> unsafe { &mut self.inner.ptr.as_mut().data }
> }
> }
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Display + ?Sized> fmt::Display for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Display::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for UniqueArc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}
> +
> +impl<T: fmt::Debug + ?Sized> fmt::Debug for Arc<T> {
> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
> + fmt::Debug::fmt(self.deref(), f)
> + }
> +}
> --
> 2.39.1

2023-02-08 15:19:20

by Miguel Ojeda

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

On Tue, Feb 7, 2023 at 7:52 PM Boqun Feng <[email protected]> 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

2023-02-08 16:34:25

by Boqun Feng

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

On Wed, Feb 08, 2023 at 04:19:04PM +0100, Miguel Ojeda wrote:
> On Tue, Feb 7, 2023 at 7:52 PM Boqun Feng <[email protected]> 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

2023-02-08 16:57:00

by Miguel Ojeda

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

On Wed, Feb 8, 2023 at 5:34 PM Boqun Feng <[email protected]> wrote:
>
> Hmm.. I'm OK with this change, but it's not a typo ;-)

By typo I meant the "sampe", not the other changes -- sorry, I should
have been more clear.

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

Yeah, I don't mind one way or the other (in fact, personally I prefer
uppercase slightly because it is a bit easier to "scan" visually to
see where it starts after the prefixes). The lowercase one is just the
one we have used so far for Rust (which I picked looking at what Linus
et al. usually do).

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

I see, makes sense, thanks!

Cheers,
Miguel

2023-02-08 16:59:24

by Boqun Feng

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

On Wed, Feb 08, 2023 at 05:56:43PM +0100, Miguel Ojeda wrote:
> On Wed, Feb 8, 2023 at 5:34 PM Boqun Feng <[email protected]> wrote:
> >
> > Hmm.. I'm OK with this change, but it's not a typo ;-)
>
> By typo I meant the "sampe", not the other changes -- sorry, I should
> have been more clear.

Ah, good eyes! Sorry I missed that twice: one when submitting and one
you mention it's a typo ;-(


Regards,
Boqun

>
> > 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
> > ;-)
>
> Yeah, I don't mind one way or the other (in fact, personally I prefer
> uppercase slightly because it is a bit easier to "scan" visually to
> see where it starts after the prefixes). The lowercase one is just the
> one we have used so far for Rust (which I picked looking at what Linus
> et al. usually do).
>
> > 2) avoid using "`" in the title to save space because title space
> > is precious.
>
> I see, makes sense, thanks!
>
> Cheers,
> Miguel

2023-04-10 03:14:07

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] rust: sync: Arc: Implement Debug and Display

On Tue, Feb 7, 2023 at 7:52 PM Boqun Feng <[email protected]> wrote:
>
> I found that our Arc doesn't implement `Debug` or `Display` when I tried
> to play with them, therefore add these implementation.

Applied to `rust-next` (with the few changes mentioned). Thanks!

Cheers,
Miguel