I started refactoring some of the innards of core::fmt, which then resulted in realising that some chunks of user facing code in fmt_macros will need tweaking.
My strawman is that the underlying flags should be expressed as an explicit bitmap, but not exposed to the users, instead a series of getters and setters would exposed on
Formatter. The remaining question to my mind is whether the api should explicitly create an accessor for each field in the bitset, eg
fmter.flags.is_alternate() -> bool fmter.flags.set_alternate(true)
Or a single method and an enum for the flags:
fmter.flags.get(Flag::Alternate) -> bool fmter.flags.set(Flag::Alternate) fmter.flags.unset(Flag::Alternate)
My preference is the second, but I would appreciate feedback.
Finally, the implementation of fmt::Pointer requires saving and resetting the flags. My belief is that this shoudl return an opaque wrapper for the underlying storage:
struct RawFlags(u32); let raw = fmter.flags.get_raw() // -> RawFlags; fmter.set_raw(raw)
Feedback would definitely be appreciated though.