From f6839a4ceb1940bdb0fce765b5e72f5eb0d46fc7 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 31 Oct 2021 22:22:53 -0700 Subject: [PATCH] files: implement Debug for MergeResult, display byte vector as string --- lib/src/files.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/src/files.rs b/lib/src/files.rs index 5a6bb5551..3730305c9 100644 --- a/lib/src/files.rs +++ b/lib/src/files.rs @@ -192,12 +192,24 @@ impl Debug for MergeHunk { } } -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone)] pub enum MergeResult { Resolved(Vec), Conflict(Vec), } +impl Debug for MergeResult { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + match self { + MergeResult::Resolved(data) => f + .debug_tuple("Resolved") + .field(&String::from_utf8_lossy(data)) + .finish(), + MergeResult::Conflict(hunks) => f.debug_tuple("Conflict").field(hunks).finish(), + } + } +} + /// A region where the base and two sides match. #[derive(Debug, PartialEq, Eq, Clone)] struct SyncRegion {