You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if you could add support for display modifiers, so that e.g. format!("{size:>10}") prints the value of the size with a total width of (at least) 10 characters, aligned to the right, and format!("{size:<10.3}") left-aligns the value and uses exactly 3 decimal places.
This is useful e.g. to display values in a column layout. In a perfect world something like below is what I'm looking for, but this may be a bit too much.
1.0 B
2.1kB
4.0MB
12.2GB
The text was updated successfully, but these errors were encountered:
Oh nevermind, I see now that by default it already has exactly 3 significant digits. That's perfect! (Formatting the total width is easy by doing format!("{:>10}", format!("{size}").)
There's a 0.6x branch with a new with_scale() option that can be used to explicitly set the number of decimal places that I'll merge into master after release 0.5 (and you can use it today), but that's not to be confused with width/precision (assuming that was what you intended).
If you don't mind, I'm going to re-open this issue because it would be interesting to see what native integration we can support with rust's format specifiers. It might end up going nowhere, but it doesn't mean we can't explore it and see. Perhaps we can translate a precision specifier like {:.N} into a call to with_scale(N) directly, which would be nice!
Hey, thanks for the nice crate!
It would be great if you could add support for display modifiers, so that e.g.
format!("{size:>10}")
prints the value of the size with a total width of (at least)10
characters, aligned to the right, andformat!("{size:<10.3}")
left-aligns the value and uses exactly3
decimal places.This is useful e.g. to display values in a column layout. In a perfect world something like below is what I'm looking for, but this may be a bit too much.
The text was updated successfully, but these errors were encountered: