Open
Description
fn main() {
foo("abcdefghijklmnopqrstuvwxyz".to_string(), "abcdefghijklmnopqrstuvwxyz".to_string());
}
gets, as expected, formatted to:
fn main() {
foo(
"abcdefghijklmnopqrstuvwxyz".to_string(),
"abcdefghijklmnopqrstuvwxyz".to_string(),
);
}
However,
fn main() {
assert_eq!("abcdefghijklmnopqrstuvwxyz".to_string(), "abcdefghijklmnopqrstuvwxyz".to_string());
}
gets formatted as:
fn main() {
assert_eq!(
"abcdefghijklmnopqrstuvwxyz".to_string(),
"abcdefghijklmnopqrstuvwxyz".to_string()
);
}
No trailing comma after the second parameter.
And even worse, function calls in one of the assert_eq!
parameters get the same treatment:
fn main() {
assert_eq!(foo("abcdefghijklmnopqrstuvwxyz".to_string(), "abcdefghijklmnopqrstuvwxyz".to_string()), "abcdefghijklmnopqrstuvwxyz".to_string());
}
gets formatted as:
fn main() {
assert_eq!(
foo(
"abcdefghijklmnopqrstuvwxyz".to_string(),
"abcdefghijklmnopqrstuvwxyz".to_string()
),
"abcdefghijklmnopqrstuvwxyz".to_string()
);
}
No trailing comma after the second parameter of foo
.
And if you have a trailing comma and a parameter gets shorter, the trailing comma stays.
fn main() {
assert_eq!(
foo(
"abcdef".to_string(),
"abcdef".to_string(),
),
"abcdefghijklmnopqrstuvwxyz".to_string()
);
}
gets formatted as:
fn main() {
assert_eq!(
foo("abcdef".to_string(), "abcdef".to_string(),),
"abcdefghijklmnopqrstuvwxyz".to_string()
);
}
I understand that trailings commas can change the meaning of macros, but it seems assert_eq!
is already special cased.
Even more than the trailing comma after assert_eq!
's second parameter, the handling of trailing commas in function calls in one of assert_eq!
's parameter seems to me pretty inconvenient.
Thanks for the hard work on such a useful tool.