MCPcopy Index your code
hub / github.com/RustPython/RustPython / add_magnitude_separators_for_char

Method add_magnitude_separators_for_char

crates/common/src/format.rs:364–380  ·  view source on GitHub ↗
(
        magnitude_str: String,
        inter: i32,
        sep: char,
        disp_digit_cnt: i32,
    )

Source from the content-addressed store, hash-verified

362 }
363
364 fn add_magnitude_separators_for_char(
365 magnitude_str: String,
366 inter: i32,
367 sep: char,
368 disp_digit_cnt: i32,
369 ) -> String {
370 // Don't add separators to the floating decimal point of numbers
371 let mut parts = magnitude_str.splitn(2, '.');
372 let magnitude_int_str = parts.next().unwrap().to_string();
373 let dec_digit_cnt = magnitude_str.len() as i32 - magnitude_int_str.len() as i32;
374 let int_digit_cnt = disp_digit_cnt - dec_digit_cnt;
375 let mut result = Self::separate_integer(magnitude_int_str, inter, sep, int_digit_cnt);
376 if let Some(part) = parts.next() {
377 result.push_str(&format!(".{part}"))
378 }
379 result
380 }
381
382 fn separate_integer(
383 magnitude_str: String,

Callers

nothing calls this directly

Calls 6

splitnMethod · 0.80
to_stringMethod · 0.80
unwrapMethod · 0.45
nextMethod · 0.45
lenMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected