tcal_rs 0.2.0

Number theory functions library - Rust port of libqalculate number theory module
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub struct PriceFormatter;

impl PriceFormatter {
    pub fn format(value: i64) -> String {
        let s = value.to_string();
        let chars: Vec<char> = s.chars().collect();
        let mut result = String::new();

        for (i, c) in chars.iter().enumerate() {
            if i > 0 && (chars.len() - i) % 3 == 0 {
                result.push(',');
            }
            result.push(*c);
        }

        result
    }
}