Improve Debug and Display for PeerId (#1019)

* Improve Debug and Display for PeerId

* Update core/src/peer_id.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>
This commit is contained in:
Pierre Krieger 2019-03-23 10:08:07 +01:00 committed by GitHub
parent 34db72a080
commit 538c3dffdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,15 @@ pub struct PeerId {
impl fmt::Debug for PeerId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "PeerId({})", self.to_base58())
f.debug_tuple("PeerId")
.field(&self.to_base58())
.finish()
}
}
impl fmt::Display for PeerId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.to_base58().fmt(f)
}
}