-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add attributes for Format derive to use Debug2Format on specific fields #662
Conversation
cddcb3e
to
92a4b69
Compare
92a4b69
to
98603a8
Compare
Looks really good! Thank you @mattico! |
Since I am not super proficient with macros I'd like @jonas-schievink to take a quick look before merging. |
Great to see this, thanks! bors r+ |
Build succeeded: |
|
||
if let Some(FormatOption::Debug2Format) = format_opt { | ||
stmts.push(quote!(defmt::export::fmt(&defmt::Debug2Format(&#ident)))); | ||
} else if let Some(FormatOption::Display2Format) = format_opt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose these didn't need to be if let
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, either normal if-else or match might be better suited.
I often have structs or enums where most fields impl
Format
, but a few third-party types do not. It is a pain to have to manually implFormat
for the whole type when only one field doesn't work. I added an attribute that lets you override specific fields to useDebug2Format
orDisplay2Format
like so: