Skip to content

Commit b90b820

Browse files
authored
Merge pull request #658 from uuid-rs/fix/alternate-format
Always use hyphenated format regardless of flags
2 parents 52197cd + 1af8269 commit b90b820

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

src/fmt.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,14 @@ impl fmt::Display for Variant {
4242

4343
impl fmt::LowerHex for Uuid {
4444
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45-
if f.alternate() {
46-
fmt::LowerHex::fmt(self.as_simple(), f)
47-
} else {
48-
fmt::LowerHex::fmt(self.as_hyphenated(), f)
49-
}
45+
fmt::LowerHex::fmt(self.as_hyphenated(), f)
5046
}
5147
}
5248

5349
impl fmt::UpperHex for Uuid {
5450
#[inline]
5551
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56-
if f.alternate() {
57-
fmt::UpperHex::fmt(self.as_simple(), f)
58-
} else {
59-
fmt::UpperHex::fmt(self.as_hyphenated(), f)
60-
}
52+
fmt::UpperHex::fmt(self.as_hyphenated(), f)
6153
}
6254
}
6355

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,8 @@ mod tests {
12191219
check!(buf, "{:X}", u, 36, |c| c.is_uppercase()
12201220
|| c.is_digit(10)
12211221
|| c == '-');
1222-
check!(buf, "{:#x}", u, 32, |c| c.is_lowercase() || c.is_digit(10));
1223-
check!(buf, "{:#X}", u, 32, |c| c.is_uppercase() || c.is_digit(10));
1222+
check!(buf, "{:#x}", u, 36, |c| c.is_lowercase() || c.is_digit(10) || c == '-');
1223+
check!(buf, "{:#X}", u, 36, |c| c.is_uppercase() || c.is_digit(10) || c == '-');
12241224

12251225
check!(buf, "{:X}", u.hyphenated(), 36, |c| c.is_uppercase()
12261226
|| c.is_digit(10)

0 commit comments

Comments
 (0)