From e7eaf5b4a2f37c1742d06ccf37bae7f83ce3b00d Mon Sep 17 00:00:00 2001 From: KodrAus Date: Tue, 31 Jan 2023 15:18:44 +1000 Subject: [PATCH 1/2] always use hyphenated format regardless of flags --- src/fmt.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/fmt.rs b/src/fmt.rs index cd7a112a..92b40422 100644 --- a/src/fmt.rs +++ b/src/fmt.rs @@ -42,22 +42,14 @@ impl fmt::Display for Variant { impl fmt::LowerHex for Uuid { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if f.alternate() { - fmt::LowerHex::fmt(self.as_simple(), f) - } else { - fmt::LowerHex::fmt(self.as_hyphenated(), f) - } + fmt::LowerHex::fmt(self.as_hyphenated(), f) } } impl fmt::UpperHex for Uuid { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if f.alternate() { - fmt::UpperHex::fmt(self.as_simple(), f) - } else { - fmt::UpperHex::fmt(self.as_hyphenated(), f) - } + fmt::UpperHex::fmt(self.as_hyphenated(), f) } } From 1af8269957b784650ea39cd4b114e575d1b96c12 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Wed, 1 Feb 2023 12:56:43 +1000 Subject: [PATCH 2/2] fix up tests around alternative format --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 49ef8416..8be4feb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1219,8 +1219,8 @@ mod tests { check!(buf, "{:X}", u, 36, |c| c.is_uppercase() || c.is_digit(10) || c == '-'); - check!(buf, "{:#x}", u, 32, |c| c.is_lowercase() || c.is_digit(10)); - check!(buf, "{:#X}", u, 32, |c| c.is_uppercase() || c.is_digit(10)); + check!(buf, "{:#x}", u, 36, |c| c.is_lowercase() || c.is_digit(10) || c == '-'); + check!(buf, "{:#X}", u, 36, |c| c.is_uppercase() || c.is_digit(10) || c == '-'); check!(buf, "{:X}", u.hyphenated(), 36, |c| c.is_uppercase() || c.is_digit(10)