Skip to main content

format_cost

Function format_cost 

Source
pub fn format_cost(cost: f64) -> String
Expand description

Formats a USD amount as "$1,234.56" (comma-grouped dollars, two decimals).

Unlike format_compact, money is never abbreviated to K/M/B — that would drop the cents — so long totals are kept readable with thousands separators instead. Negative amounts render as "-$1.23".

§Examples

use vct_core::utils::format_cost;

assert_eq!(format_cost(0.0), "$0.00");
assert_eq!(format_cost(1234.5), "$1,234.50");