MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_tokens

Function format_tokens

atomic-core/src/change/attestation.rs:1223–1231  ·  view source on GitHub ↗

Format a token count with K/M suffixes.

(tokens: u64)

Source from the content-addressed store, hash-verified

1221
1222/// Format a token count with K/M suffixes.
1223fn format_tokens(tokens: u64) -> String {
1224 if tokens >= 1_000_000 {
1225 format!("{:.1}M", tokens as f64 / 1_000_000.0)
1226 } else if tokens >= 1_000 {
1227 format!("{:.1}k", tokens as f64 / 1_000.0)
1228 } else {
1229 format!("{}", tokens)
1230 }
1231}
1232
1233/// Format a duration in milliseconds to a human-readable string.
1234fn format_duration_ms(ms: u64) -> String {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected