MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / add_grouped

Function add_grouped

compiler/src/modules/vm/handlers/format.rs:308–316  ·  view source on GitHub ↗
(digits: &str, group: usize, sep: u8)

Source from the content-addressed store, hash-verified

306}
307
308fn add_grouped(digits: &str, group: usize, sep: u8) -> String {
309 let mut out = String::with_capacity(digits.len() + digits.len() / group);
310 let chars: alloc::vec::Vec<char> = digits.chars().collect();
311 for (i, &c) in chars.iter().enumerate() {
312 if i > 0 && (chars.len() - i).is_multiple_of(group) { out.push(sep as char); }
313 out.push(c);
314 }
315 out
316}
317
318fn add_thousands_float(s: &str, sep: u8) -> String {
319 /* Insert separators only in the integer portion (before `.` / `e`). */

Callers 2

format_intFunction · 0.85
add_thousands_floatFunction · 0.85

Calls 4

collectMethod · 0.80
pushMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected