Skip to main content

Module quantity

Module quantity 

Source
Expand description

Deterministic ordering for GroupedQuantity.

Everything that renders or serialises a grouped quantity goes through ordered_components or grouped_quantity_fmt, so the human table, Markdown, JSON, YAML, LaTeX, Typst, schema.org and library outputs all agree on one order.

That ordering is a published contract, not a local convention: cookcli-core renders its shopping list through these functions, and the snapshot tests pinning the order live in CookCLI, two crates downstream. Changing it changes their output.

Functions§

grouped_quantity_fmt
Render grouped the way its own Display impl does — the components joined with ", " — but in ordered_components order.
ordered_components
The components of grouped, ordered by unit name, the unitless component first.