#![allow(dead_code, deprecated, unused_variables, unused_mut)] use std::fmt; struct Length(i32); impl fmt::UpperHex for Length { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let val = self.0; fmt::UpperHex::fmt(&val, f) } } fn main() { let l = Length(i32::MAX); assert_eq!(format!("l as hex is: {l:X}"), "l as hex is: 7FFFFFFF"); assert_eq!(format!("l as hex is: {l:#010X}"), "l as hex is: 0x7FFFFFFF"); }