Repository: actix/actix (language: rust)

Issue:
Implement Debug manually for Addr, WeakAddr and possible others to not require the actor to implement Debug
As can be seen in the [docs](https://docs.rs/actix/0.12.0/actix/struct.Addr.html#impl-Debug) currently, the `Debug` impl on `Addr` requires the actor to also implement `Debug`. This is not actually needed as its not used.

```rust
impl<A: Debug + Actor> Debug for Addr<A>
```

Implementing this manually as

```rust
impl<A> Debug for Addr<A>
```

would fix that.

This also applies to `WeakAddr` and probably other types, and maybe also other derived traits.


Discussion / hints:
It's the downside of using derive macro. I had similar suggestion to remove them and use manual impl when possible.
Hi @robjtede I am actually new to Rust ecosystem and still learning Rust. Thought the best way would be to contribute to open source. I would like to take this issue up. Any guidance would be awesome. Thanks!
@meehawk You'd implement `std::fmt::Debug` manually instead of `#[derive(Debug)]`. For example

```rust
impl<A> fmt::Debug for Addr<A> {
    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt.debug_struct("Addr")
            .field("tx", &self.tx)
            .finish()
    }
}
```

The same applies to `WeakAddr`, `Recipient` and `WeakRecipient` at least, and you might have to implement it manually in a similar way for some of the fields of these structs (e.g. `AddressSender`).
@sdroege feeling a bit lost here. Can you refer me to a doc if possible?
Documentation for?
Implementing a custom Debug trait
See https://doc.rust-lang.org/stable/std/fmt/trait.Debug.html#examples and the example I wrote [above](https://github.com/actix/actix/issues/506#issuecomment-900527285).

Fix patch:
diff --git a/actix/src/address/mod.rs b/actix/src/address/mod.rs
index bc58fcfb9..0cef8d30a 100644
--- a/actix/src/address/mod.rs
+++ b/actix/src/address/mod.rs
@@ -73,7 +73,6 @@ impl<T> fmt::Display for SendError<T> {
 }
 
 /// The address of an actor.
-#[derive(Debug)]
 pub struct Addr<A: Actor> {
     tx: AddressSender<A>,
 }
@@ -179,8 +178,13 @@ impl<A: Actor> Hash for Addr<A> {
     }
 }
 
+impl<A: Actor> fmt::Debug for Addr<A> {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt.debug_struct("Addr").field("tx", &self.tx).finish()
+    }
+}
+
 /// A weakly referenced counterpart to `Addr<A>`.
-#[derive(Debug)]
 pub struct WeakAddr<A: Actor> {
     wtx: WeakAddressSender<A>,
 }
@@ -222,12 +226,18 @@ impl<A: Actor> Clone for WeakAddr<A> {
     }
 }
 
-/// The [`Recipient`] type allows to send one specific message to an
-/// actor.
+impl<A: Actor> fmt::Debug for WeakAddr<A> {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt.debug_struct("WeakAddr")
+            .field("wtx", &self.wtx)
+            .finish()
+    }
+}
+
+/// The [`Recipient`] type allows to send one specific message to an actor.
 ///
-/// You can get a recipient using the `Addr::recipient()` method. It
-/// is possible to use the `Clone::clone()` method to get a cloned
-/// recipient.
+/// You can get a recipient using the `Addr::recipient()` method. It is possible
+/// to use the `Clone::clone()` method to get a cloned recipient.
 pub struct Recipient<M: Message>
 where
     M: Message + Send,


Test patch: