@@ -6,49 +6,13 @@ A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
6
6
7
7
``` toml
8
8
indent_style = " Block"
9
- array_width = 80
10
9
reorder_imported_names = true
11
10
```
12
11
13
12
# Configuration Options
14
13
15
14
Below you find a detailed visual guide on all the supported configuration options of rustfmt:
16
15
17
- ## ` array_horizontal_layout_threshold `
18
-
19
- How many elements array must have before rustfmt uses horizontal layout.
20
- Use this option to prevent a huge array from being vertically formatted.
21
-
22
- - ** Default value** : ` 0 `
23
- - ** Possible values** : any positive integer
24
-
25
- ** Note:** A value of ` 0 ` results in [ ` indent_style ` ] ( #indent_style ) being applied regardless of a line's width.
26
-
27
- #### ` 0 ` (default):
28
-
29
- ``` rust
30
- // Each element will be placed on its own line.
31
- let a = vec! [
32
- 0 ,
33
- 1 ,
34
- 2 ,
35
- 3 ,
36
- 4 ,
37
- ...
38
- 999 ,
39
- 1000 ,
40
- ];
41
- ```
42
-
43
- #### ` 1000 ` :
44
-
45
- ``` rust
46
- // Each element will be placed on the same line as much as possible.
47
- let a = vec! [
48
- 0 , 1 , 2 , 3 , 4 , ...
49
- ... , 999 , 1000 ,
50
- ];
51
- ```
52
16
53
17
## ` indent_style `
54
18
@@ -279,22 +243,6 @@ fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
279
243
280
244
See also: [ ` where_density ` ] ( #where_density ) , [ ` where_layout ` ] ( #where_layout ) .
281
245
282
- ## ` array_width `
283
-
284
- Maximum width of an array literal before falling back to vertical formatting
285
-
286
- - ** Default value** : ` 60 `
287
- - ** Possible values** : any positive integer
288
-
289
- ** Note:** A value of ` 0 ` results in [ ` indent_style ` ] ( #indent_style ) being applied regardless of a line's width.
290
-
291
- #### Lines shorter than ` array_width ` :
292
- ``` rust
293
- let lorem = vec! [" ipsum" , " dolor" , " sit" , " amet" , " consectetur" , " adipiscing" , " elit" ];
294
- ```
295
-
296
- #### Lines longer than ` array_width ` :
297
- See [ ` indent_style ` ] ( #indent_style ) .
298
246
299
247
## ` same_line_attributes `
300
248
@@ -341,6 +289,66 @@ enum Lorem {
341
289
}
342
290
```
343
291
292
+ ## ` use_small_heuristics `
293
+
294
+ Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.
295
+
296
+ - ** Default value** : ` true `
297
+ - ** Possible values** : ` true ` , ` false `
298
+
299
+ #### ` true ` (default):
300
+
301
+ ``` rust
302
+ enum Lorem {
303
+ Ipsum ,
304
+ Dolor (bool ),
305
+ Sit { amet : Consectetur , adipiscing : Elit },
306
+ }
307
+
308
+ fn main () {
309
+ lorem (
310
+ " lorem" ,
311
+ " ipsum" ,
312
+ " dolor" ,
313
+ " sit" ,
314
+ " amet" ,
315
+ " consectetur" ,
316
+ " adipiscing" ,
317
+ );
318
+
319
+ let lorem = Lorem { ipsum : dolor , sit : amet };
320
+
321
+ let lorem = if ipsum { dolor } else { sit };
322
+ }
323
+ ```
324
+
325
+ #### ` false ` :
326
+
327
+ ``` rust
328
+ enum Lorem {
329
+ Ipsum ,
330
+ Dolor (bool ),
331
+ Sit {
332
+ amet : Consectetur ,
333
+ adipiscing : Elit ,
334
+ },
335
+ }
336
+
337
+ fn main () {
338
+ lorem (" lorem" , " ipsum" , " dolor" , " sit" , " amet" , " consectetur" , " adipiscing" );
339
+
340
+ let lorem = Lorem {
341
+ ipsum : dolor ,
342
+ sit : amet ,
343
+ };
344
+
345
+ let lorem = if ipsum {
346
+ dolor
347
+ } else {
348
+ sit
349
+ };
350
+ }
351
+ ```
344
352
345
353
## ` binop_separator `
346
354
@@ -409,22 +417,6 @@ let lorem = ipsum.dolor()
409
417
. elit ();
410
418
```
411
419
412
- See also [ ` chain_width ` ] ( #chain_width ) .
413
-
414
- ## ` chain_width `
415
-
416
- Maximum length of a chain to fit on a single line
417
-
418
- - ** Default value** : ` 60 `
419
- - ** Possible values** : any positive integer
420
-
421
- #### Lines shorter than ` chain_width ` :
422
- ``` rust
423
- let lorem = ipsum . dolor (). sit (). amet (). consectetur (). adipiscing (). elit ();
424
- ```
425
-
426
- #### Lines longer than ` chain_width ` :
427
- See [ ` chain_indent ` ] ( #chain_indent ) .
428
420
429
421
430
422
## ` combine_control_expr `
@@ -883,23 +875,7 @@ struct Dolor<T>
883
875
}
884
876
```
885
877
886
- ## ` fn_call_width `
887
-
888
- Maximum width of the args of a function call before falling back to vertical formatting
889
-
890
- - ** Default value** : ` 60 `
891
- - ** Possible values** : any positive integer
892
-
893
- ** Note:** A value of ` 0 ` results in vertical formatting being applied regardless of a line's width.
894
-
895
- #### Function call shorter than ` fn_call_width ` :
896
- ``` rust
897
- lorem (" lorem" , " ipsum" , " dolor" , " sit" , " amet" , " consectetur" , " adipiscing" , " elit" );
898
- ```
899
-
900
- #### Function call longer than ` fn_call_width ` :
901
878
902
- See [ ` indent_style ` ] ( #indent_style ) .
903
879
904
880
## ` fn_empty_single_line `
905
881
@@ -1533,30 +1509,6 @@ it contains a `#X` (with `X` being a number) in parentheses following the
1533
1509
1534
1510
See also [ ` report_todo ` ] ( #report_todo ) .
1535
1511
1536
- ## ` single_line_if_else_max_width `
1537
-
1538
- Maximum line length for single line if-else expressions.
1539
-
1540
- - ** Default value** : ` 50 `
1541
- - ** Possible values** : any positive integer
1542
-
1543
- ** Note:** A value of ` 0 ` results in if-else expressions being broken regardless of their line's width.
1544
-
1545
- #### Lines shorter than ` single_line_if_else_max_width ` :
1546
- ``` rust
1547
- let lorem = if ipsum { dolor } else { sit };
1548
- ```
1549
-
1550
- #### Lines longer than ` single_line_if_else_max_width ` :
1551
- ``` rust
1552
- let lorem = if ipsum {
1553
- dolor
1554
- } else {
1555
- sit
1556
- };
1557
- ```
1558
-
1559
- See also: [ ` control_brace_style ` ] ( #control_brace_style ) .
1560
1512
1561
1513
## ` skip_children `
1562
1514
@@ -1768,56 +1720,8 @@ let lorem = Lorem {
1768
1720
};
1769
1721
```
1770
1722
1771
- See also: [ ` indent_style ` ] ( #indent_style ) , [ ` struct_lit_width ` ] ( #struct_lit_width ) .
1772
-
1773
- ## ` struct_lit_width `
1774
-
1775
- Maximum width in the body of a struct lit before falling back to vertical formatting
1776
-
1777
- - ** Default value** : ` 18 `
1778
- - ** Possible values** : any positive integer
1779
-
1780
- ** Note:** A value of ` 0 ` results in vertical formatting being applied regardless of a line's width.
1781
-
1782
- #### Lines shorter than ` struct_lit_width ` :
1783
- ``` rust
1784
- let lorem = Lorem { ipsum : dolor , sit : amet };
1785
- ```
1786
-
1787
- #### Lines longer than ` struct_lit_width ` :
1788
- See [ ` indent_style ` ] ( #indent_style ) .
1789
-
1790
- See also: [ ` struct_lit_single_line ` ] ( #struct_lit_single_line ) , [ ` indent_style ` ] ( #indent_style ) .
1791
-
1792
- ## ` struct_variant_width `
1793
-
1794
- Maximum width in the body of a struct variant before falling back to vertical formatting
1795
-
1796
- - ** Default value** : ` 35 `
1797
- - ** Possible values** : any positive integer
1798
-
1799
- ** Note:** A value of ` 0 ` results in vertical formatting being applied regardless of a line's width.
1800
-
1801
- #### Struct variants shorter than ` struct_variant_width ` :
1802
- ``` rust
1803
- enum Lorem {
1804
- Ipsum ,
1805
- Dolor (bool ),
1806
- Sit { amet : Consectetur , adipiscing : Elit },
1807
- }
1808
- ```
1723
+ See also: [ ` indent_style ` ] ( #indent_style ) .
1809
1724
1810
- #### Struct variants longer than ` struct_variant_width ` :
1811
- ``` rust
1812
- enum Lorem {
1813
- Ipsum ,
1814
- Dolor (bool ),
1815
- Sit {
1816
- amet : Consectetur ,
1817
- adipiscing : Elit ,
1818
- },
1819
- }
1820
- ```
1821
1725
1822
1726
## ` tab_spaces `
1823
1727
0 commit comments