I don't really like that when I use #[derive(Debug)]
on an enum and print it, it prints a comma after the value of the enum type. I don't understand why, because that's not an array, so the comma doesn't separate any values.
Here is the code:
#[derive(Debug)]
enum Foo {
Bar(String)
}
fn main() {
let foo = Foo::Bar(String::from("Hello"));
println!("{:#?}", foo);
}
It prints:
Bar(
"Hello",
) // ^ Why this?
In my opinion, it looks a bit ugly. Is it there, because it's on a new line? Is it like a separator of statements like the semicolon?
Is there anybody that thinks that this comma is redundant and ugly? I'm the only one in the community who thinks like that? I understand that commas like the last one in this example have some advantages like consistency and for diffs:
struct Point {
x: f32,
y: f32,
z: f32,
}
But in the previous case that is output to the terminal, not source code, so I find no reason for that comma to be there.