Formats a number with comma separators (e.g. 243302 -> "243,302").
(n: u64)
| 56 | |
| 57 | /// Formats a number with comma separators (e.g. 243302 -> "243,302"). |
| 58 | pub fn format_number(n: u64) -> String { |
| 59 | let s = n.to_string(); |
| 60 | let mut result = String::new(); |
| 61 | for (i, ch) in s.chars().rev().enumerate() { |
| 62 | if i > 0 && i % 3 == 0 { |
| 63 | result.push(','); |
| 64 | } |
| 65 | result.push(ch); |
| 66 | } |
| 67 | result.chars().rev().collect() |
| 68 | } |
| 69 | |
| 70 | /// Formats a single table cell with left-aligned label and right-aligned value. |
| 71 | fn format_cell(label: &str, value: &str, width: usize) -> String { |
no test coverage detected