From f3485c9efb95ca0d0699c5060e1dc29b04211bb0 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 6 Apr 2024 00:44:27 +0900 Subject: [PATCH] repo_path: make Debug formatting of RepoPathComponent less verbose Since RepoPath is formatted as a string, it should be okay for RepoPathComponent to do the same. --- lib/src/repo_path.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/src/repo_path.rs b/lib/src/repo_path.rs index 68abae74d..6a8716ddb 100644 --- a/lib/src/repo_path.rs +++ b/lib/src/repo_path.rs @@ -28,7 +28,7 @@ use crate::content_hash::ContentHash; use crate::file_util; /// Owned `RepoPath` component. -#[derive(ContentHash, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] +#[derive(ContentHash, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct RepoPathComponentBuf { // Don't add more fields. Eq, Hash, and Ord must be compatible with the // borrowed RepoPathComponent type. @@ -36,7 +36,7 @@ pub struct RepoPathComponentBuf { } /// Borrowed `RepoPath` component. -#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Hash, RefCastCustom)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, RefCastCustom)] #[repr(transparent)] pub struct RepoPathComponent { value: str, @@ -59,6 +59,18 @@ impl RepoPathComponent { } } +impl Debug for RepoPathComponent { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", &self.value) + } +} + +impl Debug for RepoPathComponentBuf { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + ::fmt(self, f) + } +} + impl From<&str> for RepoPathComponentBuf { fn from(value: &str) -> Self { RepoPathComponentBuf::from(value.to_owned())