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
We currently rely on the sprintf crate for printf like formatting in the {:num ...} formatter. While it handles a lot it does not handle everything (e.g. thousand separator etc). While this is fine for now with only break values needing this, we may need stronger support when table support lands:
Two options:
numfmt: Arguably the largest feature addition, but using a formatting spec that is somewhat foreign to most.
format_num: Adds comma-only thousand separator with familiar (but slightly different - based on D3) printf syntax (minus % prefix). Also adds SI-unit and a bunch of other features (but fewer than numfmt)
Both are negligible in terms of binary size/compile time so a real option is to have both options available. Very little is lost by switching to format_num for the {:num ...} formatter and we could have auto detection of the format string to conditionally pass it to numfmt or format_num
I'm afraid that if we go with format_num, we'll later discover a feature we want and we'd have to bit the formatting spec bullet anyway to go to numfmt. A 3rd option is to handroll a numeric formatter, which gives us a lot of control but is also a pain to maintain.
Activity
teunbrand commentedon Jun 9, 2026
I'm afraid that if we go with format_num, we'll later discover a feature we want and we'd have to bit the formatting spec bullet anyway to go to numfmt. A 3rd option is to handroll a numeric formatter, which gives us a lot of control but is also a pain to maintain.
thomasp85 commentedon Jun 9, 2026
well, my argument is that we can support both formats with a very little fallout in terms of binary size etc
thomasp85 commentedon Jun 9, 2026
numfmt has poorer support for scientific notation (it just kicks in at certain thresholds) so I'm not super fond of that either...
We should def not provide our own formatter I think
teunbrand commentedon Jun 9, 2026
Well I suppose either or both options are an improvement over the sprintf crate which advertises itself with the following:
thomasp85 commentedon Jun 12, 2026
lol - it was chosen for that specific use case so we shouldn't read too much into that
thomasp85 commentedon Nov 6, 2026
This will be handled by zygos