chiark / gitweb /
Handle the 'alternate' formatting flag.
authorSimon Tatham <anakin@pobox.com>
Sat, 12 Apr 2025 12:19:05 +0000 (13:19 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 12 Apr 2025 12:19:05 +0000 (13:19 +0100)
Suppresses the optimisation of omitting the 0x on single-decimal-digit
nimbers.

src/finitenimber.rs

index b7ea0bb62916195be5cdb536fd9e13c4f7c261f7..469cd061c95751a6851ffc6a9d06aed856d776af 100644 (file)
@@ -49,7 +49,10 @@ impl Debug for FiniteNimberRef<'_> {
 
 impl Display for FiniteNimber {
     fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
-        if self.to_ref().level() < WORDLEVELS && self.0[0] < 10 {
+        if !f.alternate()
+            && self.to_ref().level() < WORDLEVELS
+            && self.0[0] < 10
+        {
             write!(f, "*{}", self.0[0])
         } else {
             write!(f, "*0x")?;