Skip to content

A Case Against Separators #3798

Closed
Closed
@mitsuhiko

Description

@mitsuhiko

There are two places where rust currently users separators instead of terminators where the constructs are usually line terminated: struct fields and match arms:

struct Foo {
   left: int,
   right: int
}

let x = match foo() {
  None => 0,
  Some(num) => num
}

Here is why I think this is a bad idea: diffs. At the moment if you add a field to the struct at the end most diff tools will show two modified lines which causes conflicts if two developers add an entry. This is pretty annoying. For match there is currently a way to avoid that by wrapping the arms in {} in which case there is no terminator at all and the diff succeeds. The struct however at the moment requires the commas. I am not sure why, but I think it's because of the initializer syntax.

I understand that an argument against that could be to always add a terminating comma but history has shown that developers will not do that because they don't see the benefit of it (and it also looks unexpected).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions