[RFC 0/5] rust: sync: Arc: Implement Debug and Display

Boqun Feng posted 5 patches 2 years, 10 months ago
There is a newer version of this series
[RFC 0/5] rust: sync: Arc: Implement Debug and Display
Posted by Boqun Feng 2 years, 10 months ago
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 #5:

	[..] rust_print: 1
	[..] rust_print: UniqueArc { inner: Arc { refcount: 1, data: "hello, world" } }
	[..] rust_print: [samples/rust/rust_print.rs:34] c = Arc {
	[..]     refcount: 2,
	[..]     data: "hello, world",
	[..] }
	[..] rust_print: Arc {
	[..]     refcount: 0x1,
	[..]     data: "hello, world",
	[..] }

Note that I make the `Debug` implementation of `Arc` also print the
current reference count, which I think may be useful: myself sometimes
wonder "how many references exist at this point" during my own
development. But I'm open to suggestions and changes.

Wedson, I know that you are considering to get rid of `ArcBorrow`, so
the patch #3 may have some conflicts with what you may be working on.
I'm happy to wait and rebase since this series is not something urgent
;-)

Suggestions and comments are welcome!

Regards,
Boqun