MCPcopy Create free account
hub / github.com/elastic/devfiler / humanize_count

Function humanize_count

src/ui/util.rs:113–123  ·  view source on GitHub ↗

Format a count to a nice representation optimized for human readability.

(x: u64)

Source from the content-addressed store, hash-verified

111
112/// Format a count to a nice representation optimized for human readability.
113pub fn humanize_count(x: u64) -> HumanCount {
114 if x > 10u64.pow(9) {
115 HumanCount(x as f32 / 1e9, 2, "B")
116 } else if x > 10u64.pow(6) {
117 HumanCount(x as f32 / 1e6, 2, "M")
118 } else if x > 10u64.pow(3) {
119 HumanCount(x as f32 / 1e3, 2, "K")
120 } else {
121 HumanCount(x as f32, 0, "")
122 }
123}
124
125#[derive(Debug)]
126pub struct HumanCount(f32, usize, &'static str);

Callers 1

draw_count_columnFunction · 0.85

Calls 1

HumanCountClass · 0.85

Tested by

no test coverage detected