Closed wyager closed 2 months ago
Do you have a short example of where this is useful?
@jonathanpallant Sure - when writing code that will be used on embedded or desktop, it's pretty common to use a macro adapter like https://github.com/embassy-rs/embassy/blob/ac06ca2fa0aa061a0053336433fa9cbfad5212ca/embassy-sync/src/fmt.rs which switches whatever!
between log::whatever!
and defmt::whatever!
If the object you are logging is non-defmt (e.g. NorFlashErrorKind
), you must wrap it in a Debug2Format
to use it with defmt. However, if you do that, now the whatever!
macro will fail when you compile for desktop.
This PR fixes that issue. Now, something wrapped in Debug2Format
will compile whether using defmt
or log
as your macro implementation.
Oh! Right, that makes perfect sense.
@Urhengulas any thoughts on this one?
Useful for if you're writing code that switches between defmt::whatever and log::whatever or core::whatever using macros