From 7c5bd26049ad795e8f99a16d2cbb89f6789e87f9 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 5 Dec 2021 18:29:04 +0100 Subject: [PATCH] Implement custom Debug for Time --- src/files/commands.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/files/commands.rs b/src/files/commands.rs index adbd470..a7422a4 100644 --- a/src/files/commands.rs +++ b/src/files/commands.rs @@ -43,12 +43,18 @@ impl Spanned { // } // } -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Time { pub hour: u8, pub min: u8, } +impl fmt::Debug for Time { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:02}:{:02}", self.hour, self.min) + } +} + impl Time { pub fn new(hour: u32, min: u32) -> Option { if hour < 24 && min < 60 || hour == 24 && min == 0 {