D7604: rust-hg-path: implement more readable custom Debug for HgPath{, Buf}

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Dec 17 04:17:46 EST 2019


Closed by commit rHG4b3c8df189bc: rust-hg-path: implement more readable custom Debug for HgPath{,Buf} (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7604?vs=18618&id=18803

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7604/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7604

AFFECTED FILES
  rust/hg-core/src/utils/hg_path.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/utils/hg_path.rs b/rust/hg-core/src/utils/hg_path.rs
--- a/rust/hg-core/src/utils/hg_path.rs
+++ b/rust/hg-core/src/utils/hg_path.rs
@@ -77,7 +77,7 @@
 // `#[repr(transparent)]`.
 // Anyway, `Slice` representation and layout are considered implementation
 // detail, are not documented and must not be relied upon.
-#[derive(Eq, Ord, PartialEq, PartialOrd, Debug, Hash)]
+#[derive(Eq, Ord, PartialEq, PartialOrd, Hash)]
 pub struct HgPath {
     inner: [u8],
 }
@@ -181,13 +181,19 @@
     }
 }
 
+impl fmt::Debug for HgPath {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "HgPath({:?})", String::from_utf8_lossy(&self.inner))
+    }
+}
+
 impl fmt::Display for HgPath {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", String::from_utf8_lossy(&self.inner))
     }
 }
 
-#[derive(Eq, Ord, Clone, PartialEq, PartialOrd, Debug, Hash)]
+#[derive(Eq, Ord, Clone, PartialEq, PartialOrd, Hash)]
 pub struct HgPathBuf {
     inner: Vec<u8>,
 }
@@ -210,6 +216,12 @@
     }
 }
 
+impl fmt::Debug for HgPathBuf {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "HgPathBuf({:?})", String::from_utf8_lossy(&self.inner))
+    }
+}
+
 impl fmt::Display for HgPathBuf {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", String::from_utf8_lossy(&self.inner))



To: martinvonz, #hg-reviewers, kevincox, Alphare, pulkit
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list