Inconsistency between precision and width attributes in display format

Precision can be provided as a constant in the format string, as a named parameter or a positional parameter. For example there are these 3 possibilities to display pi as 3.142:

    let pi = 3.141592;
    println!("{:.3}", pi);
    println!("{:.precision$}", pi, precision=3);
    println!("{:.*}", 3, pi);

But width can only be provided in the first two forms and not as a positional parameter. For example to right-align with a specified width:

    let one = 1;
    println!("{:>3}", one);
    println!("{:>width$}", one, width=3);
    // println!("{:>*}", 3, one); // => error: invalid format string: expected `'}'`, found `'*'`

The corresponding third possibility doesn’t compile.

What is the justification of this inconsistency?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.