]> git.lizzy.rs Git - rust.git/blob - Configurations.md
Use FnSig in rewrite_fn() and rewrite_fn_base()
[rust.git] / Configurations.md
1 # Configuring Rustfmt
2
3 Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file.
4
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
6
7 ```toml
8 array_layout = "Block"
9 array_width = 80
10 reorder_imported_names = true
11 ```
12
13 # Configuration Options
14
15 Below you find a detailed visual guide on all the supported configuration options of rustfmt:
16
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 [`array_layout`](#array_layout) 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
53 ## `array_layout`
54
55 Indent on arrays
56
57 - **Default value**: `"Block"`
58 - **Possible values**: `"Block"`, `"Visual"`
59
60 #### `"Block"` (default):
61
62 ```rust
63 let lorem = vec![
64     "ipsum",
65     "dolor",
66     "sit",
67     "amet",
68     "consectetur",
69     "adipiscing",
70     "elit",
71 ];
72 ```
73
74 #### `"Visual"`:
75
76 ```rust
77 let lorem = vec!["ipsum",
78                  "dolor",
79                  "sit",
80                  "amet",
81                  "consectetur",
82                  "adipiscing",
83                  "elit"];
84 ```
85
86 ## `array_width`
87
88 Maximum width of an array literal before falling back to vertical formatting
89
90 - **Default value**: `60`
91 - **Possible values**: any positive integer
92
93 **Note:** A value of `0` results in [`array_layout`](#array_layout) being applied regardless of a line's width.
94
95 #### Lines shorter than `array_width`:
96 ```rust
97 let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit"];
98 ```
99
100 #### Lines longer than `array_width`:
101 See [`array_layout`](#array_layout).
102
103 ## `attributes_on_same_line_as_field`
104
105 Try to put attributes on the same line as fields
106
107 - **Default value**: `true`
108 - **Possible values**: `true`, `false`
109
110 #### `true` (default):
111
112 ```rust
113 struct Lorem {
114     #[serde(rename = "Ipsum")] ipsum: usize,
115     #[serde(rename = "Dolor")] dolor: usize,
116     #[serde(rename = "Amet")] amet: usize,
117 }
118 ```
119
120 #### `false`:
121
122 ```rust
123 struct Lorem {
124     #[serde(rename = "Ipsum")]
125     ipsum: usize,
126     #[serde(rename = "Dolor")]
127     dolor: usize,
128     #[serde(rename = "Amet")]
129     amet: usize,
130 }
131 ```
132
133 ## `attributes_on_same_line_as_variant`
134
135 Try to put attributes on the same line as variants
136
137 - **Default value**: `true`
138 - **Possible values**: `true`, `false`
139
140 #### `true` (default):
141
142 ```rust
143 enum Lorem {
144     #[serde(skip_serializing)] Ipsum,
145     #[serde(skip_serializing)] Dolor,
146     #[serde(skip_serializing)] Amet,
147 }
148 ```
149
150 #### `false`:
151
152 ```rust
153 enum Lorem {
154     #[serde(skip_serializing)]
155     Ipsum,
156     #[serde(skip_serializing)]
157     Dolor,
158     #[serde(skip_serializing)]
159     Amet,
160 }
161 ```
162
163 ## `binop_separator`
164
165 Where to put a binary operator when a binary expression goes multiline.
166
167 - **Default value**: `"Front"`
168 - **Possible values**: `"Front"`, `"Back"`
169
170 #### `"Front"` (default):
171
172 ```rust
173 let or = foo
174     || bar
175     || foobar;
176
177 let sum = 1234
178     + 5678
179     + 910;
180
181 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
182     ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
183 ```
184
185 #### `"Back"`:
186
187 ```rust
188 let or = foo ||
189     bar ||
190     foobar;
191
192 let sum = 1234 +
193     5678 +
194     910;
195
196 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
197     bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
198 ```
199
200 ## `chain_indent`
201
202 Indentation of chain
203
204 - **Default value**: `"Block"`
205 - **Possible values**: `"Block"`, `"Visual"`
206
207 #### `"Block"` (default):
208
209 ```rust
210 let lorem = ipsum
211     .dolor()
212     .sit()
213     .amet()
214     .consectetur()
215     .adipiscing()
216     .elit();
217 ```
218
219 #### `"Visual"`:
220
221 ```rust
222 let lorem = ipsum.dolor()
223                  .sit()
224                  .amet()
225                  .consectetur()
226                  .adipiscing()
227                  .elit();
228 ```
229
230 See also [`chain_one_line_max`](#chain_one_line_max).
231
232 ## `chain_one_line_max`
233
234 Maximum length of a chain to fit on a single line
235
236 - **Default value**: `60`
237 - **Possible values**: any positive integer
238
239 #### Lines shorter than `chain_one_line_max`:
240 ```rust
241 let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
242 ```
243
244 #### Lines longer than `chain_one_line_max`:
245 See [`chain_indent`](#chain_indent).
246
247 ## `chain_split_single_child`
248
249 Split a chain with a single child if its length exceeds [`chain_one_line_max`](#chain_one_line_max).
250
251 - **Default value**: `false`
252 - **Possible values**: `false`, `true`
253
254 #### `false` (default):
255
256 ```rust
257 let files = fs::read_dir("tests/coverage/source").expect("Couldn't read source dir");
258 ```
259
260 #### `true`:
261
262 ```rust
263 let files = fs::read_dir("tests/coverage/source")
264     .expect("Couldn't read source dir");
265 ```
266
267 See also [`chain_one_line_max`](#chain_one_line_max).
268
269 ## `closure_block_indent_threshold`
270
271 How many lines a closure must have before it is block indented. -1 means never use block indent.
272
273 - **Default value**: `7`
274 - **Possible values**: `-1`, or any positive integer
275
276 #### Closures shorter than `closure_block_indent_threshold`:
277 ```rust
278 lorem_ipsum(|| {
279                 println!("lorem");
280                 println!("ipsum");
281                 println!("dolor");
282                 println!("sit");
283                 println!("amet");
284             });
285 ```
286
287 #### Closures longer than `closure_block_indent_threshold`:
288 ```rust
289 lorem_ipsum(|| {
290     println!("lorem");
291     println!("ipsum");
292     println!("dolor");
293     println!("sit");
294     println!("amet");
295     println!("consectetur");
296     println!("adipiscing");
297     println!("elit");
298 });
299 ```
300
301 **Note**: This option only takes effect when `fn_call_style` is set to `"Visual"`.
302
303 ## `combine_control_expr`
304
305 Combine control expressions with function calls.
306
307 - **Default value**: `true`
308 - **Possible values**: `true`, `false`
309
310 #### `true` (default):
311
312 ```rust
313 fn example() {
314     // If
315     foo!(if x {
316         foo();
317     } else {
318         bar();
319     });
320
321     // IfLet
322     foo!(if let Some(..) = x {
323         foo();
324     } else {
325         bar();
326     });
327
328     // While
329     foo!(while x {
330         foo();
331         bar();
332     });
333
334     // WhileLet
335     foo!(while let Some(..) = x {
336         foo();
337         bar();
338     });
339
340     // ForLoop
341     foo!(for x in y {
342         foo();
343         bar();
344     });
345
346     // Loop
347     foo!(loop {
348         foo();
349         bar();
350     });
351 }
352 ```
353
354 #### `false`:
355
356 ```rust
357 ```
358
359 ## `comment_width`
360
361 Maximum length of comments. No effect unless`wrap_comments = true`.
362
363 - **Default value**: `80`
364 - **Possible values**: any positive integer
365
366 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
367
368 #### Comments shorter than `comment_width`:
369 ```rust
370 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
371 ```
372
373 #### Comments longer than `comment_width`:
374 ```rust
375 // Lorem ipsum dolor sit amet,
376 // consectetur adipiscing elit.
377 ```
378
379 See also [`wrap_comments`](#wrap_comments).
380
381 ## `condense_wildcard_suffixes`
382
383 Replace strings of _ wildcards by a single .. in tuple patterns
384
385 - **Default value**: `false`
386 - **Possible values**: `true`, `false`
387
388 #### `false` (default):
389
390 ```rust
391 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
392 ```
393
394 #### `true`:
395
396 ```rust
397 let (lorem, ipsum, ..) = (1, 2, 3, 4);
398 ```
399
400 ## `control_style`
401
402 Indent style for control flow statements
403
404 - **Default value**: `"Rfc"`
405 - **Possible values**: `"Rfc"`, `"Legacy"`
406
407 #### `"Rfc"` (default):
408
409 ```rust
410 if lorem_ipsum &&
411     dolor_sit &&
412     amet_consectetur
413 {
414     // ...
415 }
416 ```
417
418 #### `"Legacy"`:
419
420 ```rust
421 if lorem_ipsum &&
422    dolor_sit &&
423    amet_consectetur {
424     // ...
425 }
426 ```
427
428 See also: [`control_brace_style`](#control_brace_style).
429
430 ## `control_brace_style`
431
432 Brace style for control flow constructs
433
434 - **Default value**: `"AlwaysSameLine"`
435 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
436
437 #### `"AlwaysSameLine"` (default):
438
439 ```rust
440 if lorem {
441     println!("ipsum!");
442 } else {
443     println!("dolor!");
444 }
445 ```
446
447 #### `"AlwaysNextLine"`:
448
449 ```rust
450 if lorem
451 {
452     println!("ipsum!");
453 }
454 else
455 {
456     println!("dolor!");
457 }
458 ```
459
460 #### `"ClosingNextLine"`:
461
462 ```rust
463 if lorem {
464     println!("ipsum!");
465 }
466 else {
467     println!("dolor!");
468 }
469 ```
470
471 ## `disable_all_formatting`
472
473 Don't reformat anything
474
475 - **Default value**: `false`
476 - **Possible values**: `true`, `false`
477
478 ## `error_on_line_overflow`
479
480 Error if unable to get all lines within max_width
481
482 - **Default value**: `true`
483 - **Possible values**: `true`, `false`
484
485 See also [`max_width`](#max_width).
486
487 ## `fn_args_density`
488
489 Argument density in functions
490
491 - **Default value**: `"Tall"`
492 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
493
494 #### `"Tall"` (default):
495
496 ```rust
497 trait Lorem {
498     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
499
500     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
501         // body
502     }
503
504     fn lorem(
505         ipsum: Ipsum,
506         dolor: Dolor,
507         sit: Sit,
508         amet: Amet,
509         consectetur: onsectetur,
510         adipiscing: Adipiscing,
511         elit: Elit,
512     );
513
514     fn lorem(
515         ipsum: Ipsum,
516         dolor: Dolor,
517         sit: Sit,
518         amet: Amet,
519         consectetur: onsectetur,
520         adipiscing: Adipiscing,
521         elit: Elit,
522     ) {
523         // body
524     }
525 }
526 ```
527
528 #### `"Compressed"`:
529
530 ```rust
531 trait Lorem {
532     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
533
534     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
535         // body
536     }
537
538     fn lorem(
539         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
540         adipiscing: Adipiscing, elit: Elit,
541     );
542
543     fn lorem(
544         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
545         adipiscing: Adipiscing, elit: Elit,
546     ) {
547         // body
548     }
549 }
550 ```
551
552 #### `"CompressedIfEmpty"`:
553
554 ```rust
555 trait Lorem {
556     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
557
558     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
559         // body
560     }
561
562     fn lorem(
563         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
564         adipiscing: Adipiscing, elit: Elit,
565     );
566
567     fn lorem(
568         ipsum: Ipsum,
569         dolor: Dolor,
570         sit: Sit,
571         amet: Amet,
572         consectetur: onsectetur,
573         adipiscing: Adipiscing,
574         elit: Elit,
575     ) {
576         // body
577     }
578 }
579 ```
580
581 #### `"Vertical"`:
582
583 ```rust
584 trait Lorem {
585     fn lorem(ipsum: Ipsum,
586              dolor: Dolor,
587              sit: Sit,
588              amet: Amet);
589
590     fn lorem(ipsum: Ipsum,
591              dolor: Dolor,
592              sit: Sit,
593              amet: Amet) {
594         // body
595     }
596
597     fn lorem(ipsum: Ipsum,
598              dolor: Dolor,
599              sit: Sit,
600              amet: Amet,
601              consectetur: onsectetur,
602              adipiscing: Adipiscing,
603              elit: Elit);
604
605     fn lorem(ipsum: Ipsum,
606              dolor: Dolor,
607              sit: Sit,
608              amet: Amet,
609              consectetur: onsectetur,
610              adipiscing: Adipiscing,
611              elit: Elit) {
612         // body
613     }
614 }
615 ```
616
617 ## `fn_args_layout`
618
619 Layout of function arguments and tuple structs
620
621 - **Default value**: `"Block"`
622 - **Possible values**: `"Block"`, `"Visual"`
623
624 #### `"Block"` (default):
625
626 ```rust
627 fn lorem() {}
628
629 fn lorem(ipsum: usize) {}
630
631 fn lorem(
632     ipsum: usize,
633     dolor: usize,
634     sit: usize,
635     amet: usize,
636     consectetur: usize,
637     adipiscing: usize,
638     elit: usize,
639 ) {
640     // body
641 }
642 ```
643
644 #### `"Visual"`:
645
646 ```rust
647 fn lorem() {}
648
649 fn lorem(ipsum: usize) {}
650
651 fn lorem(ipsum: usize,
652          dolor: usize,
653          sit: usize,
654          amet: usize,
655          consectetur: usize,
656          adipiscing: usize,
657          elit: usize) {
658     // body
659 }
660 ```
661
662 ## `fn_args_paren_newline`
663
664 If function argument parenthesis goes on a newline
665
666 - **Default value**: `false`
667 - **Possible values**: `true`, `false`
668
669 #### `false` (default):
670
671 ```rust
672 fn lorem(
673     ipsum: Ipsum,
674     dolor: Dolor,
675     sit: Sit,
676     amet: Amet,
677 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
678     // body
679 }
680 ```
681
682 #### `true`:
683
684 ```rust
685 fn lorem
686     (
687     ipsum: Ipsum,
688     dolor: Dolor,
689     sit: Sit,
690     amet: Amet,
691 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
692     // body
693 }
694 ```
695
696 ## `fn_brace_style`
697
698 Brace style for functions
699
700 - **Default value**: `"SameLineWhere"`
701 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
702
703 #### `"SameLineWhere"` (default):
704
705 ```rust
706 fn lorem() {
707     // body
708 }
709
710 fn lorem(ipsum: usize) {
711     // body
712 }
713
714 fn lorem<T>(ipsum: T)
715 where
716     T: Add + Sub + Mul + Div,
717 {
718     // body
719 }
720 ```
721
722 #### `"AlwaysNextLine"`:
723
724 ```rust
725 fn lorem()
726 {
727     // body
728 }
729
730 fn lorem(ipsum: usize)
731 {
732     // body
733 }
734
735 fn lorem<T>(ipsum: T)
736 where
737     T: Add + Sub + Mul + Div,
738 {
739     // body
740 }
741 ```
742
743 #### `"PreferSameLine"`:
744
745 ```rust
746 fn lorem() {
747     // body
748 }
749
750 fn lorem(ipsum: usize) {
751     // body
752 }
753
754 fn lorem<T>(ipsum: T)
755 where
756     T: Add + Sub + Mul + Div, {
757     // body
758 }
759 ```
760
761 ## `fn_call_style`
762
763 Indentation for function calls, etc.
764
765 - **Default value**: `"Block"`
766 - **Possible values**: `"Block"`, `"Visual"`
767
768 #### `"Block"` (default):
769
770 ```rust
771 lorem(
772     "lorem",
773     "ipsum",
774     "dolor",
775     "sit",
776     "amet",
777     "consectetur",
778     "adipiscing",
779     "elit",
780 );
781 ```
782
783 #### `"Visual"`:
784
785 ```rust
786 lorem("lorem",
787       "ipsum",
788       "dolor",
789       "sit",
790       "amet",
791       "consectetur",
792       "adipiscing",
793       "elit");
794 ```
795
796 ## `fn_call_width`
797
798 Maximum width of the args of a function call before falling back to vertical formatting
799
800 - **Default value**: `60`
801 - **Possible values**: any positive integer
802
803 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
804
805 #### Function call shorter than `fn_call_width`:
806 ```rust
807 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
808 ```
809
810 #### Function call longer than `fn_call_width`:
811
812 See [`fn_call_style`](#fn_call_style).
813
814 ## `fn_empty_single_line`
815
816 Put empty-body functions on a single line
817
818 - **Default value**: `true`
819 - **Possible values**: `true`, `false`
820
821 #### `true` (default):
822
823 ```rust
824 fn lorem() {}
825 ```
826
827 #### `false`:
828
829 ```rust
830 fn lorem() {
831 }
832 ```
833
834 See also [`control_brace_style`](#control_brace_style).
835
836 ## `fn_return_indent`
837
838 Location of return type in function declaration
839
840 - **Default value**: `"WithArgs"`
841 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
842
843 #### `"WithArgs"` (default):
844
845 ```rust
846 fn lorem(ipsum: Ipsum,
847          dolor: Dolor,
848          sit: Sit,
849          amet: Amet,
850          consectetur: Consectetur,
851          adipiscing: Adipiscing)
852          -> Elit
853     where Ipsum: Eq
854 {
855     // body
856 }
857
858 ```
859
860 #### `"WithWhereClause"`:
861
862 ```rust
863 fn lorem(ipsum: Ipsum,
864          dolor: Dolor,
865          sit: Sit,
866          amet: Amet,
867          consectetur: Consectetur,
868          adipiscing: Adipiscing)
869     -> Elit
870     where Ipsum: Eq
871 {
872     // body
873 }
874
875 ```
876
877 **Note**: This option only takes effect when `fn_call_style` is set to `"Visual"`.
878
879 ## `fn_single_line`
880
881 Put single-expression functions on a single line
882
883 - **Default value**: `false`
884 - **Possible values**: `true`, `false`
885
886 #### `false` (default):
887
888 ```rust
889 fn lorem() -> usize {
890     42
891 }
892
893 fn lorem() -> usize {
894     let ipsum = 42;
895     ipsum
896 }
897 ```
898
899 #### `true`:
900
901 ```rust
902 fn lorem() -> usize { 42 }
903
904 fn lorem() -> usize {
905     let ipsum = 42;
906     ipsum
907 }
908 ```
909
910 See also [`control_brace_style`](#control_brace_style).
911
912 ## `force_explicit_abi`
913
914 Always print the abi for extern items
915
916 - **Default value**: `true`
917 - **Possible values**: `true`, `false`
918
919 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
920
921 #### `true` (default):
922
923 ```rust
924 extern "C" {
925     pub static lorem: c_int;
926 }
927 ```
928
929 #### `false`:
930
931 ```rust
932 extern {
933     pub static lorem: c_int;
934 }
935 ```
936
937 ## `force_format_strings`
938
939 Always format string literals
940
941 - **Default value**: `false`
942 - **Possible values**: `true`, `false`
943
944 See [`format_strings`](#format_strings).
945
946 See also [`max_width`](#max_width).
947
948 ## `format_strings`
949
950 Format string literals where necessary
951
952 - **Default value**: `false`
953 - **Possible values**: `true`, `false`
954
955 #### `false` (default):
956
957 ```rust
958 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
959 ```
960
961 #### `true`:
962
963 ```rust
964 let lorem =
965     "ipsum dolor sit amet consectetur \
966      adipiscing elit lorem ipsum dolor sit";
967 ```
968
969 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
970
971 ## `generics_indent`
972
973 Indentation of generics
974
975 - **Default value**: `"Block"`
976 - **Possible values**: `"Block"`, `"Visual"`
977
978 #### `"Block"` (default):
979
980 ```rust
981 fn lorem<
982     Ipsum: Eq = usize,
983     Dolor: Eq = usize,
984     Sit: Eq = usize,
985     Amet: Eq = usize,
986     Adipiscing: Eq = usize,
987     Consectetur: Eq = usize,
988     Elit: Eq = usize
989 >(
990     ipsum: Ipsum,
991     dolor: Dolor,
992     sit: Sit,
993     amet: Amet,
994     adipiscing: Adipiscing,
995     consectetur: Consectetur,
996     elit: Elit,
997 ) -> T {
998     // body
999 }
1000 ```
1001
1002 #### `"Visual"`:
1003
1004 ```rust
1005 fn lorem<Ipsum: Eq = usize,
1006          Dolor: Eq = usize,
1007          Sit: Eq = usize,
1008          Amet: Eq = usize,
1009          Adipiscing: Eq = usize,
1010          Consectetur: Eq = usize,
1011          Elit: Eq = usize>
1012     (ipsum: Ipsum,
1013      dolor: Dolor,
1014      sit: Sit,
1015      amet: Amet,
1016      adipiscing: Adipiscing,
1017      consectetur: Consectetur,
1018      elit: Elit)
1019      -> T {
1020     // body
1021 }
1022 ```
1023
1024 ## `hard_tabs`
1025
1026 Use tab characters for indentation, spaces for alignment
1027
1028 - **Default value**: `false`
1029 - **Possible values**: `true`, `false`
1030
1031 #### `false` (default):
1032
1033 ```rust
1034 fn lorem() -> usize {
1035     42 // spaces before 42
1036 }
1037 ```
1038
1039 #### `true`:
1040
1041 ```rust
1042 fn lorem() -> usize {
1043         42 // tabs before 42
1044 }
1045 ```
1046
1047 See also: [`tab_spaces`](#tab_spaces).
1048
1049 ## `impl_empty_single_line`
1050
1051 Put empty-body implementations on a single line
1052
1053 - **Default value**: `true`
1054 - **Possible values**: `true`, `false`
1055
1056 #### `true` (default):
1057
1058 ```rust
1059 impl Lorem {}
1060 ```
1061
1062 #### `false`:
1063
1064 ```rust
1065 impl Lorem {
1066 }
1067 ```
1068
1069 See also [`item_brace_style`](#item_brace_style).
1070
1071 ## `indent_match_arms`
1072
1073 Indent match arms instead of keeping them at the same indentation level as the match keyword
1074
1075 - **Default value**: `true`
1076 - **Possible values**: `true`, `false`
1077
1078 #### `true` (default):
1079
1080 ```rust
1081 match lorem {
1082     Lorem::Ipsum => (),
1083     Lorem::Dolor => (),
1084     Lorem::Sit => (),
1085     Lorem::Amet => (),
1086 }
1087 ```
1088
1089 #### `false`:
1090
1091 ```rust
1092 match lorem {
1093 Lorem::Ipsum => (),
1094 Lorem::Dolor => (),
1095 Lorem::Sit => (),
1096 Lorem::Amet => (),
1097 }
1098 ```
1099
1100 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1101
1102 ## `imports_indent`
1103
1104 Indent style of imports
1105
1106 - **Default Value**: `"Visual"`
1107 - **Possible values**: `"Block"`, `"Visual"`
1108
1109 #### `"Visual"` (default):
1110
1111 ```rust
1112 use foo::{xxx,
1113           yyy,
1114           zzz};
1115 ```
1116
1117 #### `"Block"`:
1118
1119 ```rust
1120 use foo::{
1121     xxx,
1122     yyy,
1123     zzz,
1124 };
1125 ```
1126
1127 See also: [`imports_layout`](#imports_layout).
1128
1129 ## `imports_layout`
1130
1131 Item layout inside a imports block
1132
1133 - **Default value**: "Mixed"
1134 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1135
1136 #### `"Mixed"` (default):
1137
1138 ```rust
1139 use foo::{xxx, yyy, zzz};
1140
1141 use foo::{aaa, bbb, ccc,
1142           ddd, eee, fff};
1143 ```
1144
1145 #### `"Horizontal"`:
1146
1147 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1148
1149 ```rust
1150 use foo::{xxx, yyy, zzz};
1151
1152 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1153 ```
1154
1155 #### `"HorizontalVertical"`
1156
1157 ```rust
1158 use foo::{xxx, yyy, zzz};
1159
1160 use foo::{aaa,
1161           bbb,
1162           ccc,
1163           ddd,
1164           eee,
1165           fff};
1166 ```
1167
1168 #### `"Vertical"`
1169
1170 ```rust
1171 use foo::{xxx,
1172           yyy,
1173           zzz};
1174
1175 use foo::{aaa,
1176           bbb,
1177           ccc,
1178           ddd,
1179           eee,
1180           fff};
1181 ```
1182
1183 ## `item_brace_style`
1184
1185 Brace style for structs and enums
1186
1187 - **Default value**: `"SameLineWhere"`
1188 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1189
1190 #### `"SameLineWhere"` (default):
1191
1192 ```rust
1193 struct Lorem {
1194     ipsum: bool,
1195 }
1196
1197 struct Dolor<T>
1198     where T: Eq
1199 {
1200     sit: T,
1201 }
1202 ```
1203
1204 #### `"AlwaysNextLine"`:
1205
1206 ```rust
1207 struct Lorem
1208 {
1209     ipsum: bool,
1210 }
1211
1212 struct Dolor<T>
1213     where T: Eq
1214 {
1215     sit: T,
1216 }
1217 ```
1218
1219 #### `"PreferSameLine"`:
1220
1221 ```rust
1222 struct Lorem {
1223     ipsum: bool,
1224 }
1225
1226 struct Dolor<T>
1227     where T: Eq {
1228     sit: T,
1229 }
1230 ```
1231
1232 ## `match_block_trailing_comma`
1233
1234 Put a trailing comma after a block based match arm (non-block arms are not affected)
1235
1236 - **Default value**: `false`
1237 - **Possible values**: `true`, `false`
1238
1239 #### `false` (default):
1240
1241 ```rust
1242 match lorem {
1243     Lorem::Ipsum => {
1244         println!("ipsum");
1245     }
1246     Lorem::Dolor => println!("dolor"),
1247 }
1248 ```
1249
1250 #### `true`:
1251
1252 ```rust
1253 match lorem {
1254     Lorem::Ipsum => {
1255         println!("ipsum");
1256     },
1257     Lorem::Dolor => println!("dolor"),
1258 }
1259 ```
1260
1261 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1262
1263 ## `match_pattern_separator_break_point`
1264
1265 Put a match sub-patterns' separator (`|`) in front or back.
1266
1267 - **Default value**: `"Back"`
1268 - **Possible values**: `"Back"`, `"Front"`
1269
1270 #### `"Back"` (default):
1271
1272 ```rust
1273 match m {
1274     Variant::Tag |
1275     Variant::Tag2 |
1276     Variant::Tag3 |
1277     Variant::Tag4 |
1278     Variant::Tag5 |
1279     Variant::Tag6 => {}
1280 }
1281 ```
1282
1283 #### `Front`:
1284
1285 ```rust
1286 match m {
1287     Variant::Tag
1288     | Variant::Tag2
1289     | Variant::Tag3
1290     | Variant::Tag4
1291     | Variant::Tag5
1292     | Variant::Tag6 => {}
1293 }
1294 ```
1295
1296 ## `max_width`
1297
1298 Maximum width of each line
1299
1300 - **Default value**: `100`
1301 - **Possible values**: any positive integer
1302
1303 See also [`error_on_line_overflow`](#error_on_line_overflow).
1304
1305 ## `merge_derives`
1306
1307 Merge multiple derives into a single one.
1308
1309 - **Default value**: `true`
1310 - **Possible values**: `true`, `false`
1311
1312 #### `true` (default):
1313
1314 ```rust
1315 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1316 pub enum Foo {}
1317 ```
1318
1319 #### `false`:
1320
1321 ```rust
1322 #[derive(Eq, PartialEq)]
1323 #[derive(Debug)]
1324 #[derive(Copy, Clone)]
1325 pub enum Foo {}
1326 ```
1327
1328 ## `multiline_closure_forces_block`
1329
1330 Force multiline closure bodies to be wrapped in a block
1331
1332 - **Default value**: `false`
1333 - **Possible values**: `false`, `true`
1334
1335 #### `false` (default):
1336
1337 ```rust
1338 result.and_then(|maybe_value| match maybe_value {
1339     None => ...,
1340     Some(value) => ...,
1341 })
1342 ```
1343
1344 #### `true`:
1345
1346 ```rust
1347
1348 result.and_then(|maybe_value| {
1349     match maybe_value {
1350         None => ...,
1351         Some(value) => ...,
1352     }
1353 })
1354 ```
1355
1356 ## `multiline_match_arm_forces_block`
1357
1358 Force multiline match arm bodies to be wrapped in a block
1359
1360 - **Default value**: `false`
1361 - **Possible values**: `false`, `true`
1362
1363 #### `false` (default):
1364
1365 ```rust
1366 match lorem {
1367     None => if ipsum {
1368         println!("Hello World");
1369     },
1370     Some(dolor) => ...,
1371 }
1372 ```
1373
1374 #### `true`:
1375
1376 ```rust
1377 match lorem {
1378     None => {
1379         if ipsum {
1380             println!("Hello World");
1381         }
1382     }
1383     Some(dolor) => ...,
1384 }
1385 ```
1386
1387 ## `newline_style`
1388
1389 Unix or Windows line endings
1390
1391 - **Default value**: `"Unix"`
1392 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1393
1394 ## `normalize_comments`
1395
1396 Convert /* */ comments to // comments where possible
1397
1398 - **Default value**: `false`
1399 - **Possible values**: `true`, `false`
1400
1401 #### `false` (default):
1402
1403 ```rust
1404 // Lorem ipsum:
1405 fn dolor() -> usize {}
1406
1407 /* sit amet: */
1408 fn adipiscing() -> usize {}
1409 ```
1410
1411 #### `true`:
1412
1413 ```rust
1414 // Lorem ipsum:
1415 fn dolor() -> usize {}
1416
1417 // sit amet:
1418 fn adipiscing() -> usize {}
1419 ```
1420
1421 ## `reorder_imported_names`
1422
1423 Reorder lists of names in import statements alphabetically
1424
1425 - **Default value**: `false`
1426 - **Possible values**: `true`, `false`
1427
1428 #### `false` (default):
1429
1430 ```rust
1431 use super::{lorem, ipsum, dolor, sit};
1432 ```
1433
1434 #### `true`:
1435
1436 ```rust
1437 use super::{dolor, ipsum, lorem, sit};
1438 ```
1439
1440 See also [`reorder_imports`](#reorder_imports).
1441
1442 ## `reorder_imports`
1443
1444 Reorder import statements alphabetically
1445
1446 - **Default value**: `false`
1447 - **Possible values**: `true`, `false`
1448
1449 #### `false` (default):
1450
1451 ```rust
1452 use lorem;
1453 use ipsum;
1454 use dolor;
1455 use sit;
1456 ```
1457
1458 #### `true`:
1459
1460 ```rust
1461 use dolor;
1462 use ipsum;
1463 use lorem;
1464 use sit;
1465 ```
1466
1467 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1468
1469 ## `reorder_imports_in_group`
1470
1471 Reorder import statements in group
1472
1473 - **Default value**: `false`
1474 - **Possible values**: `true`, `false`
1475
1476 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1477
1478 #### `false` (default):
1479
1480 ```rust
1481 use std::mem;
1482 use std::io;
1483
1484 use lorem;
1485 use ipsum;
1486 use dolor;
1487 use sit;
1488 ```
1489
1490 #### `true`:
1491
1492 ```rust
1493 use std::io;
1494 use std::mem;
1495
1496 use dolor;
1497 use ipsum;
1498 use lorem;
1499 use sit;
1500 ```
1501
1502 See also [`reorder_imports`](#reorder_imports).
1503
1504 ## `single_line_if_else_max_width`
1505
1506 Maximum line length for single line if-else expressions.
1507
1508 - **Default value**: `50`
1509 - **Possible values**: any positive integer
1510
1511 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1512
1513 #### Lines shorter than `single_line_if_else_max_width`:
1514 ```rust
1515 let lorem = if ipsum { dolor } else { sit };
1516 ```
1517
1518 #### Lines longer than `single_line_if_else_max_width`:
1519 ```rust
1520 let lorem = if ipsum {
1521     dolor
1522 } else {
1523     sit
1524 };
1525 ```
1526
1527 See also: [`control_brace_style`](#control_brace_style).
1528
1529 ## `skip_children`
1530
1531 Don't reformat out of line modules
1532
1533 - **Default value**: `false`
1534 - **Possible values**: `true`, `false`
1535
1536 ## `space_after_bound_colon`
1537
1538 Leave a space after the colon in a trait or lifetime bound
1539
1540 - **Default value**: `true`
1541 - **Possible values**: `true`, `false`
1542
1543 #### `true` (default):
1544
1545 ```rust
1546 fn lorem<T: Eq>(t: T) {
1547     // body
1548 }
1549 ```
1550
1551 #### `false`:
1552
1553 ```rust
1554 fn lorem<T:Eq>(t: T) {
1555     // body
1556 }
1557 ```
1558
1559 See also: [`space_before_bound`](#space_before_bound).
1560
1561 ## `struct_field_align_threshold`
1562
1563 The maximum diff of width between struct fields to be aligned with each other.
1564
1565 - **Default value** : 0
1566 - **Possible values**: any positive integer
1567
1568 #### `0` (default):
1569
1570 ```rust
1571 struct Foo {
1572     x: u32,
1573     yy: u32,
1574     zzz: u32,
1575 }
1576 ```
1577
1578 #### `20`:
1579
1580 ```rust
1581 struct Foo {
1582     x:   u32,
1583     yy:  u32,
1584     zzz: u32,
1585 }
1586 ```
1587
1588 ## `space_after_struct_lit_field_colon`
1589
1590 Leave a space after the colon in a struct literal field
1591
1592 - **Default value**: `true`
1593 - **Possible values**: `true`, `false`
1594
1595 #### `true` (default):
1596
1597 ```rust
1598 let lorem = Lorem {
1599     ipsum: dolor,
1600     sit: amet,
1601 };
1602 ```
1603
1604 #### `false`:
1605
1606 ```rust
1607 let lorem = Lorem {
1608     ipsum:dolor,
1609     sit:amet,
1610 };
1611 ```
1612
1613 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1614
1615 ## `space_after_type_annotation_colon`
1616
1617 Leave a space after the colon in a type annotation
1618
1619 - **Default value**: `true`
1620 - **Possible values**: `true`, `false`
1621
1622 #### `true` (default):
1623
1624 ```rust
1625 fn lorem<T: Eq>(t: T) {
1626     let ipsum: Dolor = sit;
1627 }
1628 ```
1629
1630 #### `false`:
1631
1632 ```rust
1633 fn lorem<T: Eq>(t:T) {
1634     let ipsum:Dolor = sit;
1635 }
1636 ```
1637
1638 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1639
1640 ## `space_before_bound`
1641
1642 Leave a space before the colon in a trait or lifetime bound
1643
1644 - **Default value**: `false`
1645 - **Possible values**: `true`, `false`
1646
1647 #### `false` (default):
1648
1649 ```rust
1650 fn lorem<T: Eq>(t: T) {
1651     let ipsum: Dolor = sit;
1652 }
1653 ```
1654
1655 #### `true`:
1656
1657 ```rust
1658 fn lorem<T : Eq>(t: T) {
1659     let ipsum: Dolor = sit;
1660 }
1661 ```
1662
1663 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1664
1665 ## `space_before_struct_lit_field_colon`
1666
1667 Leave a space before the colon in a struct literal field
1668
1669 - **Default value**: `false`
1670 - **Possible values**: `true`, `false`
1671
1672 #### `false` (default):
1673
1674 ```rust
1675 let lorem = Lorem {
1676     ipsum: dolor,
1677     sit: amet,
1678 };
1679 ```
1680
1681 #### `true`:
1682
1683 ```rust
1684 let lorem = Lorem {
1685     ipsum : dolor,
1686     sit : amet,
1687 };
1688 ```
1689
1690 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1691
1692 ## `space_before_type_annotation`
1693
1694 Leave a space before the colon in a type annotation
1695
1696 - **Default value**: `false`
1697 - **Possible values**: `true`, `false`
1698
1699 #### `false` (default):
1700
1701 ```rust
1702 fn lorem<T: Eq>(t: T) {
1703     let ipsum: Dolor = sit;
1704 }
1705 ```
1706
1707 #### `true`:
1708
1709 ```rust
1710 fn lorem<T: Eq>(t : T) {
1711     let ipsum : Dolor = sit;
1712 }
1713 ```
1714
1715 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1716
1717 ## `spaces_around_ranges`
1718
1719 Put spaces around the .. and ... range operators
1720
1721 - **Default value**: `false`
1722 - **Possible values**: `true`, `false`
1723
1724 #### `false` (default):
1725
1726 ```rust
1727 let lorem = 0..10;
1728 ```
1729
1730 #### `true`:
1731
1732 ```rust
1733 let lorem = 0 .. 10;
1734 ```
1735
1736 ## `spaces_within_angle_brackets`
1737
1738 Put spaces within non-empty generic arguments
1739
1740 - **Default value**: `false`
1741 - **Possible values**: `true`, `false`
1742
1743 #### `false` (default):
1744
1745 ```rust
1746 fn lorem<T: Eq>(t: T) {
1747     // body
1748 }
1749 ```
1750
1751 #### `true`:
1752
1753 ```rust
1754 fn lorem< T: Eq >(t: T) {
1755     // body
1756 }
1757 ```
1758
1759 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1760
1761 ## `spaces_within_parens`
1762
1763 Put spaces within non-empty parentheses
1764
1765 - **Default value**: `false`
1766 - **Possible values**: `true`, `false`
1767
1768 #### `false` (default):
1769
1770 ```rust
1771 fn lorem<T: Eq>(t: T) {
1772     let lorem = (ipsum, dolor);
1773 }
1774 ```
1775
1776 #### `true`:
1777
1778 ```rust
1779 fn lorem<T: Eq>( t: T ) {
1780     let lorem = ( ipsum, dolor );
1781 }
1782 ```
1783
1784 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1785
1786 ## `spaces_within_square_brackets`
1787
1788 Put spaces within non-empty square brackets
1789
1790 - **Default value**: `false`
1791 - **Possible values**: `true`, `false`
1792
1793 #### `false` (default):
1794
1795 ```rust
1796 let lorem: [usize; 2] = [ipsum, dolor];
1797 ```
1798
1799 #### `true`:
1800
1801 ```rust
1802 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1803 ```
1804
1805 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1806
1807 ## `struct_lit_multiline_style`
1808
1809 Multiline style on literal structs
1810
1811 - **Default value**: `"PreferSingle"`
1812 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1813
1814 #### `"PreferSingle"` (default):
1815
1816 ```rust
1817 let lorem = Lorem { ipsum: dolor, sit: amet };
1818 ```
1819
1820 #### `"ForceMulti"`:
1821
1822 ```rust
1823 let lorem = Lorem {
1824     ipsum: dolor,
1825     sit: amet,
1826 };
1827 ```
1828
1829 See also: [`struct_lit_style`](#struct_lit_style), [`struct_lit_width`](#struct_lit_width).
1830
1831 ## `struct_lit_style`
1832
1833 Style of struct definition
1834
1835 - **Default value**: `"Block"`
1836 - **Possible values**: `"Block"`, `"Visual"`
1837
1838 #### `"Block"` (default):
1839
1840 ```rust
1841 let lorem = Lorem {
1842     ipsum: dolor,
1843     sit: amet,
1844 };
1845 ```
1846
1847 #### `"Visual"`:
1848
1849 ```rust
1850 let lorem = Lorem { ipsum: dolor,
1851                     sit: amet, };
1852 ```
1853
1854 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_style`](#struct_lit_style).
1855
1856 ## `struct_lit_width`
1857
1858 Maximum width in the body of a struct lit before falling back to vertical formatting
1859
1860 - **Default value**: `18`
1861 - **Possible values**: any positive integer
1862
1863 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1864
1865 #### Lines shorter than `struct_lit_width`:
1866 ```rust
1867 let lorem = Lorem { ipsum: dolor, sit: amet };
1868 ```
1869
1870 #### Lines longer than `struct_lit_width`:
1871 See [`struct_lit_style`](#struct_lit_style).
1872
1873 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_style`](#struct_lit_style).
1874
1875 ## `struct_variant_width`
1876
1877 Maximum width in the body of a struct variant before falling back to vertical formatting
1878
1879 - **Default value**: `35`
1880 - **Possible values**: any positive integer
1881
1882 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1883
1884 #### Struct variants shorter than `struct_variant_width`:
1885 ```rust
1886 enum Lorem {
1887     Ipsum,
1888     Dolor(bool),
1889     Sit { amet: Consectetur, adipiscing: Elit },
1890 }
1891 ```
1892
1893 #### Struct variants longer than `struct_variant_width`:
1894 ```rust
1895 enum Lorem {
1896     Ipsum,
1897     Dolor(bool),
1898     Sit {
1899         amet: Consectetur,
1900         adipiscing: Elit,
1901     },
1902 }
1903 ```
1904
1905 ## `tab_spaces`
1906
1907 Number of spaces per tab
1908
1909 - **Default value**: `4`
1910 - **Possible values**: any positive integer
1911
1912 #### `4` (default):
1913
1914 ```rust
1915 fn lorem() {
1916     let ipsum = dolor();
1917     let sit = vec![
1918         "amet consectetur adipiscing elit."
1919     ];
1920 }
1921 ```
1922
1923 #### `2`:
1924
1925 ```rust
1926 fn lorem() {
1927   let ipsum = dolor();
1928   let sit = vec![
1929     "amet consectetur adipiscing elit."
1930   ];
1931 }
1932 ```
1933
1934 See also: [`hard_tabs`](#hard_tabs).
1935
1936 ## `take_source_hints`
1937
1938 Retain some formatting characteristics from the source code
1939
1940 - **Default value**: `false`
1941 - **Possible values**: `true`, `false`
1942
1943 #### `false` (default):
1944
1945 ```rust
1946 lorem
1947     .ipsum()
1948     .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
1949 ```
1950
1951 #### `true`:
1952
1953 ```rust
1954 lorem
1955     .ipsum()
1956     .dolor(|| {
1957                sit.amet()
1958                    .consectetur()
1959                    .adipiscing()
1960                    .elit();
1961            });
1962 ```
1963
1964 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
1965
1966 ## `trailing_comma`
1967
1968 How to handle trailing commas for lists
1969
1970 - **Default value**: `"Vertical"`
1971 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
1972
1973 #### `"Vertical"` (default):
1974
1975 ```rust
1976 let Lorem { ipsum, dolor, sit } = amet;
1977 let Lorem {
1978     ipsum,
1979     dolor,
1980     sit,
1981     amet,
1982     consectetur,
1983     adipiscing,
1984 } = elit;
1985 ```
1986
1987 #### `"Always"`:
1988
1989 ```rust
1990 let Lorem { ipsum, dolor, sit, } = amet;
1991 let Lorem {
1992     ipsum,
1993     dolor,
1994     sit,
1995     amet,
1996     consectetur,
1997     adipiscing,
1998 } = elit;
1999 ```
2000
2001 #### `"Never"`:
2002
2003 ```rust
2004 let Lorem { ipsum, dolor, sit } = amet;
2005 let Lorem {
2006     ipsum,
2007     dolor,
2008     sit,
2009     amet,
2010     consectetur,
2011     adipiscing
2012 } = elit;
2013 ```
2014
2015 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2016
2017 ## `trailing_semicolon`
2018
2019 Add trailing semicolon after break, continue and return
2020
2021 - **Default value**: `true`
2022 - **Possible values**: `true`, `false`
2023
2024 #### `true` (default):
2025 ```rust
2026 fn foo() -> usize {
2027     return 0;
2028 }
2029 ```
2030
2031 #### `false`:
2032 ```rust
2033 fn foo() -> usize {
2034     return 0
2035 }
2036 ```
2037
2038 ## `type_punctuation_density`
2039
2040 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2041
2042 - **Default value**: `"Wide"`
2043 - **Possible values**: `"Compressed"`, `"Wide"`
2044
2045 #### `"Wide"` (default):
2046
2047 ```rust
2048 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2049         // body
2050 }
2051 ```
2052
2053 #### `"Compressed"`:
2054
2055 ```rust
2056 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2057         // body
2058 }
2059 ```
2060
2061 ## `use_try_shorthand`
2062
2063 Replace uses of the try! macro by the ? shorthand
2064
2065 - **Default value**: `false`
2066 - **Possible values**: `true`, `false`
2067
2068 #### `false` (default):
2069
2070 ```rust
2071 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2072 ```
2073
2074 #### `true`:
2075
2076 ```rust
2077 let lorem = ipsum.map(|dolor| dolor.sit())?;
2078 ```
2079
2080 ## `where_density`
2081
2082 Density of a where clause.
2083
2084 - **Default value**: `"CompressedIfEmpty"`
2085 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2086
2087 #### `"CompressedIfEmpty"` (default):
2088
2089 ```rust
2090 trait Lorem {
2091     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2092     where Dolor: Eq;
2093
2094     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2095     where
2096         Dolor: Eq,
2097     {
2098         // body
2099     }
2100 }
2101 ```
2102
2103 #### `"Compressed"`:
2104
2105 ```rust
2106 trait Lorem {
2107     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2108     where Dolor: Eq;
2109
2110     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2111     where Dolor: Eq {
2112         // body
2113     }
2114 }
2115 ```
2116
2117 #### `"Tall"`:
2118
2119 ```rust
2120 trait Lorem {
2121     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2122     where
2123         Dolor: Eq;
2124
2125     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2126     where
2127         Dolor: Eq,
2128     {
2129         // body
2130     }
2131 }
2132 ```
2133
2134 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2135
2136 #### `"Vertical"`:
2137
2138 ```rust
2139 trait Lorem {
2140     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2141         where Dolor: Eq;
2142
2143     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2144         where Dolor: Eq
2145     {
2146         // body
2147     }
2148 }
2149 ```
2150
2151 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2152
2153 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2154
2155 ## `where_layout`
2156
2157 Element layout inside a where clause
2158
2159 - **Default value**: `"Vertical"`
2160 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2161
2162 #### `"Vertical"` (default):
2163
2164 ```rust
2165 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2166     where Ipsum: IpsumDolorSitAmet,
2167           Dolor: DolorSitAmetConsectetur
2168 {
2169     // body
2170 }
2171
2172 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2173     where Ipsum: IpsumDolorSitAmet,
2174           Dolor: DolorSitAmetConsectetur,
2175           Sit: SitAmetConsecteturAdipiscing,
2176           Amet: AmetConsecteturAdipiscingElit
2177 {
2178     // body
2179 }
2180 ```
2181
2182 #### `"Horizontal"`:
2183
2184 ```rust
2185 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2186     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2187 {
2188     // body
2189 }
2190
2191 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2192     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2193 {
2194     // body
2195 }
2196 ```
2197
2198 #### `"HorizontalVertical"`:
2199
2200 ```rust
2201 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2202     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2203 {
2204     // body
2205 }
2206
2207 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2208     where Ipsum: IpsumDolorSitAmet,
2209           Dolor: DolorSitAmetConsectetur,
2210           Sit: SitAmetConsecteturAdipiscing,
2211           Amet: AmetConsecteturAdipiscingElit
2212 {
2213     // body
2214 }
2215 ```
2216
2217 #### `"Mixed"`:
2218
2219 ```rust
2220 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2221     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2222 {
2223     // body
2224 }
2225
2226 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2227     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2228           Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2229 {
2230     // body
2231 }
2232 ```
2233
2234 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2235
2236 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2237
2238 ## `where_pred_indent`
2239
2240 Indentation style of a where predicate
2241
2242 - **Default value**: `"Visual"`
2243 - **Possible values**: `"Block"`, `"Visual"`
2244
2245 #### `"Visual"` (default):
2246
2247 ```rust
2248 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2249     where Ipsum: Eq,
2250           Dolor: Eq,
2251           Sit: Eq,
2252           Amet: Eq
2253 {
2254     // body
2255 }
2256 ```
2257
2258 #### `"Block"`:
2259
2260 ```rust
2261 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2262     where Ipsum: Eq,
2263         Dolor: Eq,
2264         Sit: Eq,
2265         Amet: Eq
2266 {
2267     // body
2268 }
2269 ```
2270
2271 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2272
2273 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2274
2275 ## `where_style`
2276
2277 Overall strategy for where clauses
2278
2279 - **Default value**: `"Rfc"`
2280 - **Possible values**: `"Rfc"`, `"Legacy"`
2281
2282 #### `"Rfc"` (default):
2283
2284 ```rust
2285 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2286 where
2287     Ipsum: Eq,
2288     Dolor: Eq,
2289     Sit: Eq,
2290     Amet: Eq,
2291 {
2292     // body
2293 }
2294 ```
2295
2296 #### `"Legacy"`:
2297
2298 ```rust
2299 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2300     where Ipsum: Eq,
2301           Dolor: Eq,
2302           Sit: Eq,
2303           Amet: Eq
2304 {
2305     // body
2306 }
2307 ```
2308
2309 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2310
2311 ## `wrap_comments`
2312
2313 Break comments to fit on the line
2314
2315 - **Default value**: `false`
2316 - **Possible values**: `true`, `false`
2317
2318 #### `false` (default):
2319
2320 ```rust
2321 // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
2322 ```
2323
2324 #### `true`:
2325
2326 ```rust
2327 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2328 // sed do eiusmod tempor incididunt ut labore et dolore
2329 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2330 // exercitation ullamco laboris nisi ut aliquip ex ea
2331 // commodo consequat.
2332 ```
2333
2334 ## `wrap_match_arms`
2335
2336 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2337
2338 - **Default value**: `true`
2339 - **Possible values**: `true`, `false`
2340
2341 #### `true` (default):
2342
2343 ```rust
2344 match lorem {
2345     true => {
2346         foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2347     }
2348     false => println!("{}", sit),
2349 }
2350 ```
2351
2352 #### `false`:
2353
2354 ```rust
2355 match lorem {
2356     true =>
2357         foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2358     false => println!("{}", sit),
2359 }
2360 ```
2361
2362 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2363
2364 ## `write_mode`
2365
2366 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2367
2368 - **Default value**: `"Overwrite"`
2369 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`