Skip to content

Commit 2ff14b0

Browse files
Remove opinions from style guide about where clauses in type alias items
1 parent f707b9c commit 2ff14b0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/doc/style-guide/src/items.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,12 @@ type VeryLongType<T, U: SomeBound>
377377
= AnEvenLongerType<T, U, Foo<T>>;
378378
```
379379

380-
Where possible avoid `where` clauses and keep type constraints inline. Where
381-
that is not possible, prefer a trailing `where` clause over one that precedes
382-
the type. Split the line before and after a trailing `where` clause (and split
383-
the `where` clause as normal) and indent before the `=` and type, e.g.,
380+
When there is a trailing `where` clause after the type, and no `where` clause
381+
present before the type, break before the `=` and indent. Then break before the
382+
`where` keyword and format the clauses normally, e.g.,
384383

385384
```rust
385+
// With only a trailing where clause
386386
type VeryLongType<T, U>
387387
= AnEvenLongerType<T, U, Foo<T>>
388388
where
@@ -392,9 +392,12 @@ where
392392

393393
When there is a `where` clause before the type, format it normally, and break
394394
after the last clause. Do not indent before the `=` to leave it visually
395-
distinct from the indented clauses.
395+
distinct from the indented clauses that precede it. If there is additionally a
396+
`where` clause after the type, break before the `where` keyword and format the
397+
clauses normally.
396398

397-
```
399+
```rust
400+
// With only a preceding where clause.
398401
type WithPrecedingWC<T, U>
399402
where
400403
T: U::AnAssociatedType,

0 commit comments

Comments
 (0)