hecatia-elegua / bilge

Use bitsized types as if they were a feature of rust.
Apache License 2.0
171 stars 17 forks source link

Add formatting implementations for LowerHex and friends #85

Open nimish opened 1 year ago

nimish commented 1 year ago

Since it's already possible to derive one for Binary, it'd make sense to allow for println("{:x}") and the other integer printing formatters. A workaround is to manually convert to the sized uint before printing but that's a little tedious.

hecatia-elegua commented 1 year ago

Feel free to implement. You could even just extend it for you own use with a custom derive macro ending its name in Bits. For structs, the LowerHex impl should just be fmt::LowerHex::fmt(&self.value.value, f). Actually, wouldn't a "normal" byte based derive LowerHex work?