From a207bc16eeafaad9f2d06506d06b10621135983c Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Wed, 6 Oct 2021 11:41:48 +0200 Subject: [PATCH 1/2] Add more traits impls to OwnedLabel. --- src/base/name/label.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/base/name/label.rs b/src/base/name/label.rs index 843ed05dd..d26ba1747 100644 --- a/src/base/name/label.rs +++ b/src/base/name/label.rs @@ -403,6 +403,7 @@ impl fmt::Debug for Label { // // This keeps the label in wire format, so the first octet is the length // octet, the remainder is the content. +#[derive(Clone, Copy)] pub struct OwnedLabel([u8; 64]); impl OwnedLabel { @@ -534,6 +535,22 @@ impl hash::Hash for OwnedLabel { } } +//--- Display and Debug + +impl fmt::Display for OwnedLabel { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_label().fmt(f) + } +} + +impl fmt::Debug for OwnedLabel { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_tuple("OwnedLabel") + .field(&self.as_label()) + .finish() + } +} + //------------ SliceLabelsIter ----------------------------------------------- /// An iterator over the labels in an octets slice. From 3c8de67aac8754df179f965d9a30748ae7e5cc52 Mon Sep 17 00:00:00 2001 From: Martin Hoffmann Date: Wed, 6 Oct 2021 12:24:24 +0200 Subject: [PATCH 2/2] Fix formatting. --- src/base/name/label.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/base/name/label.rs b/src/base/name/label.rs index d26ba1747..ce46a227c 100644 --- a/src/base/name/label.rs +++ b/src/base/name/label.rs @@ -545,9 +545,7 @@ impl fmt::Display for OwnedLabel { impl fmt::Debug for OwnedLabel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("OwnedLabel") - .field(&self.as_label()) - .finish() + f.debug_tuple("OwnedLabel").field(&self.as_label()).finish() } }