MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / format_bytes

Function format_bytes

src/display.rs:45–55  ·  view source on GitHub ↗

Formats a byte count into a human-readable string (e.g. "798.0 MB").

(bytes: u64)

Source from the content-addressed store, hash-verified

43
44/// Formats a byte count into a human-readable string (e.g. "798.0 MB").
45pub fn format_bytes(bytes: u64) -> String {
46 if bytes >= 1_073_741_824 {
47 format!("{:.1} GB", bytes as f64 / 1_073_741_824.0)
48 } else if bytes >= 1_048_576 {
49 format!("{:.1} MB", bytes as f64 / 1_048_576.0)
50 } else if bytes >= 1024 {
51 format!("{:.1} KB", bytes as f64 / 1024.0)
52 } else {
53 format!("{bytes} B")
54 }
55}
56
57/// Formats a number with comma separators (e.g. 243302 -> "243,302").
58pub fn format_number(n: u64) -> String {

Callers 3

build_stats_rowsFunction · 0.85
handle_branch_actionFunction · 0.85
handle_listFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected