Open zhongxinghong opened 1 month ago
Seems like this is related to #3626 and is the opposite of #3514
I see. with #3514, I think these can be roughly summarized into the following situations:
for max_width = 80
// 1. single line
let res = f_abc(a, b, c);
// 2. vertical
let res = f_abc(
a,
b,
c,
);
// 3. single line for line2
let res =
f_abc(a, b, c);
// 4. vertical for line2
let res =
f_abc(
a,
b,
c,
);
len \ opt | 1. prefer vertical | 2. prefer single line for line2 | 3. prefer vertical for line2 |
---|---|---|---|
1. len(line) <= 80 | single line | single line | single line |
2. len(line) > 80 and len(line2) <= 80 | vertical | single line2 | vertical line2 |
3. len(line) > 80 and len(line2) > 80 | vertical | vertical (same as now) | vertical line2 |
version
rustfmt 1.7.1-nightly (94885bc6 2024-09-01)
rustfmt.toml
example
According to the above example, rustfmt have two line break styles for long statement. But I really don't like the style 1 because it looks strange in some cases. I have to make some tricky adjustments such as rename the function name / rename some argument names / ... to change the style 1 to single line or style 2. And it bothers me too in some other situations such as match-arms. I wish to have some new options in rustfmt.toml to disable the style 1, a statement should directly be formatted to the style 2 from single line if it's too long. Thanks~