It works fine. you can't even display a value as 02x and 02X, since those are different. I suspect what is happening is that the write! macro is creating std::fmt::Arguments objects for red green blue and those Argument objects hold the information on how to display the element. Therefor it can't display it differently at different locations in the string.