Skip to content

More powerful number formatting #470

@thomasp85

Description

@thomasp85

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions