diff options
| author | Michael Goulet <michael@errs.io> | 2023-08-23 18:25:09 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-08-23 18:25:09 +0000 |
| commit | 2ff14b0050145b79769bf207b7d0bee5c98292b8 (patch) | |
| tree | 050c50bbfe789c4259b4550e294856c116a6d1ac | |
| parent | f707b9cd707d84768687caa025d483cef61ed440 (diff) | |
| download | rust-2ff14b0050145b79769bf207b7d0bee5c98292b8.tar.gz rust-2ff14b0050145b79769bf207b7d0bee5c98292b8.zip | |
Remove opinions from style guide about where clauses in type alias items
| -rw-r--r-- | src/doc/style-guide/src/items.md | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/doc/style-guide/src/items.md b/src/doc/style-guide/src/items.md index dc10f4ff15d..b215de6ad28 100644 --- a/src/doc/style-guide/src/items.md +++ b/src/doc/style-guide/src/items.md @@ -377,12 +377,12 @@ type VeryLongType<T, U: SomeBound> = AnEvenLongerType<T, U, Foo<T>>; ``` -Where possible avoid `where` clauses and keep type constraints inline. Where -that is not possible, prefer a trailing `where` clause over one that precedes -the type. Split the line before and after a trailing `where` clause (and split -the `where` clause as normal) and indent before the `=` and type, e.g., +When there is a trailing `where` clause after the type, and no `where` clause +present before the type, break before the `=` and indent. Then break before the +`where` keyword and format the clauses normally, e.g., ```rust +// With only a trailing where clause type VeryLongType<T, U> = AnEvenLongerType<T, U, Foo<T>> where @@ -392,9 +392,12 @@ where When there is a `where` clause before the type, format it normally, and break after the last clause. Do not indent before the `=` to leave it visually -distinct from the indented clauses. +distinct from the indented clauses that precede it. If there is additionally a +`where` clause after the type, break before the `where` keyword and format the +clauses normally. -``` +```rust +// With only a preceding where clause. type WithPrecedingWC<T, U> where T: U::AnAssociatedType, |
