From bc89fc77354f7d8af6628364be18550c4a45c789 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 23 Jan 2022 20:50:04 +0800 Subject: [PATCH] feat: Implement Display for hash kind (#298) This helps 'clap' and allows for a little more type-safety during declaration. --- git-hash/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-hash/src/lib.rs b/git-hash/src/lib.rs index ac101385fd0..c4f5b2495a2 100644 --- a/git-hash/src/lib.rs +++ b/git-hash/src/lib.rs @@ -96,6 +96,14 @@ impl FromStr for Kind { } } +impl std::fmt::Display for Kind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Kind::Sha1 => f.write_str("SHA1"), + } + } +} + impl Kind { /// Returns the shortest hash we support #[inline]