-
-
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
zero padding display hint diverges from core::fmt
#491
Comments
@derekdreery Would you like to look into this? |
This matches the behavior of |
Really? That is weird, but okay with me if it is consistent 🤔 |
Hmm, actually our output for |
That is also what I just tested and was about to write 😅 This code println!("{:02X}", 42);
println!("{:#02X}", 42);
println!("{:03X}", 42);
println!("{:#03X}", 42);
println!("{:04X}", 42);
println!("{:#04X}", 42); results in
I think consistency is helpful to help people not getting confused, about display hints. I'd rather vote for matching the behavior, and explude the |
core::fmt
When I made this, I tried to merge the beahvior of core::fmt and the
existing defmt formatting. Happy to do a PR to change it if that's the
consensus.
…On Sun, May 23, 2021 at 10:38 PM Johann Hemmann ***@***.***> wrote:
Hmm, actually our output for {:06x} matches {:#06x} with core::fmt - it
doesn't include the 0x unless you use #, so maybe it's fine if we change
how the padding works too?
That is also what I just tested and was about to write 😅
I think consistency is helpful to help people not getting confused, about
display hints. I'd rather vote for matching the behavior, and explude the
0x.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#491 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKT4XVCNMM5MKRHHALTTETTPFYUDANCNFSM45MDCPIQ>
.
|
@derekdreery: I would be happy if you go forward to adapt the output to match |
Hi, so there are a few differences between defmt and core::fmt:
The might be others. Would you like me to change behaviour to match for 1 and 2, just 1, or something else? |
Number one is already the case for |
@Urhengulas are you sure that having People will be familiar with how |
I see. I mainly thought about logging single hex numbers, but for something like a mac-address it makes sense to be able to exclude the |
This code:
results in these logs:
I'd expect that a display hint
:04x
results in0x002a
for42
, but it currently seems to include the0x
in the length and only results in0x2a
.06x
will currently result in the desired0x002a
, but I would expect0x000002a
.The text was updated successfully, but these errors were encountered: