@@ -378,15 +378,38 @@ type VeryLongType<T, U: SomeBound>
378
378
```
379
379
380
380
Where possible avoid ` where ` clauses and keep type constraints inline. Where
381
- that is not possible split the line before and after the ` where ` clause (and
382
- split the ` where ` clause as normal), e.g.,
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.,
383
384
384
385
``` rust
385
386
type VeryLongType <T , U >
387
+ = AnEvenLongerType <T , U , Foo <T >>
388
+ where
389
+ T : U :: AnAssociatedType ,
390
+ U : SomeBound ;
391
+ ```
392
+
393
+ When there is a ` where ` clause before the type, format it normally, and break
394
+ after the last clause. Do not indent before the ` = ` to leave it visually
395
+ distinct from the indented clauses.
396
+
397
+ ```
398
+ type WithPrecedingWC<T, U>
386
399
where
387
400
T: U::AnAssociatedType,
388
401
U: SomeBound,
389
402
= AnEvenLongerType<T, U, Foo<T>>;
403
+
404
+ // Or with both a preceding and trailing where clause.
405
+ type WithPrecedingWC<T, U>
406
+ where
407
+ T: U::AnAssociatedType,
408
+ U: SomeBound,
409
+ = AnEvenLongerType<T, U, Foo<T>>
410
+ where
411
+ T: U::AnAssociatedType2,
412
+ U: SomeBound2;
390
413
```
391
414
392
415
## Associated types
0 commit comments