3 ms·
The position of arguments is actually not required to follow the format string. From the documentation: println!("{1} {} {0} {}", 1, 2); // => "2 1 1 2" But
by dthul 6y ago
The position of arguments is actually not required to follow the format string. From the documentation:
println!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
But you are right, you cannot dynamically change the format string.
If you need this facility, there is the runtime_fmt crate which will parse the format string at runtime instead of compile time. That of course means that it can fail at runtime if the format string does not match the arguments.