The main issue I’ve encountered with rustfmt is the lack of a way to specify that function calls should be wrapped to the minimum number of lines, which is the default style (for C/C++ at least) in the code bases I’m used to. In particular:
-
If a function call requires multiple lines, rustfmt puts each argument on a separate line. Instead, I’d like to have multiple parameters on the same line, up to the max characters per line.
-
Sometimes, the opening parenthesis of a function call is quite close to the right edge column. Often in such cases to wrap the statement to the minimum number of lines rustfmt should wrap the first argument to the next line.
Example:
// unwanted
let very_long_name = very_long_function_name(param1,
param2,
param3);
// better alternative
let very_long_name = very_long_function_name(
param1, param2, param3);
// even better alternative
let very_long_name =
very_long_function_name(param1, param2, param3);
The same concerns apply to macro invocations and other similar constructs. If there is a way to get this “wrap to minimum number of lines” then I think I could enforce auto-formatting for my code.
And, it probably goes without saying that I think such mode should be the default.