In C you can use set printf's width parameter dynamically like this:
printf("%*.*f", width, precision, value);
This is how I would like it to work:
let width = 8;
let precision = 2;
let value = 1234.56789;
println!("{:*.*}", width, precision, value);
But using that syntax throws expected '}' in format string.
This kind of works:
let width = 8;
let precision = 2;
let value = 1234.56789;
println!("{:8.*}", precision, value);
But as you can see the width is not set dynamically. I assume it doesn't work because of some good reason. Is it possible to make it work in a similar way or are there any workarounds?