//! Common utilities for the examples. /// Formats a byte count into a human-readable string. pub fn format_bytes(bytes: usize) -> String { const KB: usize = 1024; const MB: usize = KB * 1024; const GB: usize = MB * 1024; if bytes >= GB { format!("{:.2} GB", bytes as f64 / GB as f64) } else if bytes >= MB { format!("{:.2} MB", bytes as f64 / MB as f64) } else if bytes >= KB { format!("{:.2} KB", bytes as f64 / KB as f64) } else { format!("{} B", bytes) } }