Skip to content

Commit

Permalink
style-guide: Move text about block vs visual indent to indentation se…
Browse files Browse the repository at this point in the history
…ction

`principles.md` includes some high-level guiding principles for
formatting, but also includes a few specific formatting provisions.
While those provisions apply in many places, the same holds true for
other high-level guidance, such as the indentation section. Move the
text about using block indent rather than visual indent to the
indentation section, so that `principles.md` can focus on guiding
principles while the top level of the style guide gives concrete
formatting recommendations.
  • Loading branch information
joshtriplett committed Jun 22, 2023
1 parent 2efe091 commit 3747d7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
18 changes: 18 additions & 0 deletions src/doc/style-guide/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ typically by using a formatting tool's default settings.
* The maximum width for a line is 100 characters.
* A tool should be configurable for all three of these variables.

#### Block indent

Prefer block indent over visual indent:

```rust
// Block indent
a_function_call(
foo,
bar,
);

// Visual indent
a_function_call(foo,
bar);
```

This makes for smaller diffs (e.g., if `a_function_call` is renamed in the above
example) and less rightward drift.

### Blank lines

Expand Down
17 changes: 0 additions & 17 deletions src/doc/style-guide/src/principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@ following principles (in rough priority order):

## Overarching guidelines

Prefer block indent over visual indent. E.g.,

```rust
// Block indent
a_function_call(
foo,
bar,
);

// Visual indent
a_function_call(foo,
bar);
```

This makes for smaller diffs (e.g., if `a_function_call` is renamed in the above
example) and less rightward drift.

Lists should have a trailing comma when followed by a newline, see the block
indent example above. This choice makes moving code (e.g., by copy and paste)
easier and makes smaller diffs.

0 comments on commit 3747d7f

Please sign in to comment.