cargo-countlines 0.1.0

A tool to count SLOC
1
2
3
4
5
6
7
8
9
10
11
12
13
pub fn format_number(num: usize) -> String {
    let s = num.to_string();
    let mut x = s.len() % 3 + 3; // the `+ 3` avoids a leading comma
    let mut out = String::new();
    for c in s.chars() {
        if x == 0 {
            out.push(',');
        }
        x = (x + 2) % 3; // x - 1 (mod 3)
        out.push(c);
    }
    out
}