I was going implement Debug for a type to support the :x? syntax in formatting (it's for debug printing in hexadecimal). I'm not sure if it's widely used, but indeed it's mentioned in the std doc and I do have potential usages for it.
The question is, the docs says :x? should also be supported through the trait Debug, but the Formatter type doesn't have a method to tell whether Debug is called by :? or :x?. After some investigation into the compiler, I found that this information is captured in the Formatter's flags. So I had a try:
called Debug with flags 0
called Debug with flags 4
called Debug with flags 16
called Debug with flags 32
So, the flags indeed tell us how the trait is called. However, the flags method is deprecated, so it should not be used in new code. Then what is the idiomatic way to support the x? syntax? Or is this syntax actually also going to be deprecated?
Thanks for pointing me to that tracking issue! At the bottom there seems to be a PR related to this. So I guess right now the way to implement this is still relying on the flags method until someday a new API is proposed?