pub fn fmt_align_fraction_strings(strings: &[&str]) -> Vec<String>
Expand description

Aligns a number of formatted fraction numbers. Valid strings are for example 1, 3.14, and -42. Aligns all with additional padding on the left so that all of them can be printed line by line in an aligned way. This means that in every line the tens digits will be aligned, the once places will be aligned, the decimal place will be aligned etc. (TODO are these the proper english terms?)

This takes the precision from the longest fractional part (without unnecessary zeroes) to align all strings.

Example Input

"-42"
"0.3214"
"1000"
"-1000.2"
"2.00000"

Example Output

"  -42     "
"    0.3214"
" 1000     "
"-1000.2   "
"    2     "
Examples found in repository?
examples/example.rs (line 7)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let input_1 = vec!["-42", "0.3214", "1000", "-1000.2", "2.00000"];
    let aligned_1 = fmt_align_fraction_strings(&input_1);
    println!("{:#?}", aligned_1);

    // or

    let input_2 = vec![
        FractionNumber::F32(-42.0),
        FractionNumber::F64(0.3214),
        FractionNumber::F64(1000.0),
        FractionNumber::F64(-1000.2),
        FractionNumber::F64(2.00000),
    ];
    let max_precision = 4;
    let aligned_2 = fmt_align_fractions(&input_2, FormatPrecision::Max(max_precision));
    println!("{:#?}", aligned_2);
}