]> git.lizzy.rs Git - rust.git/blob - Configurations.md
Configurations: document error_on_line_overflow_comments
[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_indent = "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_indent`](#array_indent) 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_indent`
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_indent`](#array_indent) 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_indent`](#array_indent).
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_width`](#chain_width).
231
232 ## `chain_width`
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_width`:
240 ```rust
241 let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
242 ```
243
244 #### Lines longer than `chain_width`:
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_width`](#chain_width).
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_width`](#chain_width).
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_indent` 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 ## `error_on_line_overflow_comments`
488
489 Error if unable to get all comment lines within `comment_width`.
490
491 - **Default value**: `true`
492 - **Possible values**: `true`, `false`
493
494 See also [`comment_width`](#comment_width).
495
496 ## `fn_args_density`
497
498 Argument density in functions
499
500 - **Default value**: `"Tall"`
501 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
502
503 #### `"Tall"` (default):
504
505 ```rust
506 trait Lorem {
507     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
508
509     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
510         // body
511     }
512
513     fn lorem(
514         ipsum: Ipsum,
515         dolor: Dolor,
516         sit: Sit,
517         amet: Amet,
518         consectetur: Consectetur,
519         adipiscing: Adipiscing,
520         elit: Elit,
521     );
522
523     fn lorem(
524         ipsum: Ipsum,
525         dolor: Dolor,
526         sit: Sit,
527         amet: Amet,
528         consectetur: Consectetur,
529         adipiscing: Adipiscing,
530         elit: Elit,
531     ) {
532         // body
533     }
534 }
535 ```
536
537 #### `"Compressed"`:
538
539 ```rust
540 trait Lorem {
541     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
542
543     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
544         // body
545     }
546
547     fn lorem(
548         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
549         adipiscing: Adipiscing, elit: Elit,
550     );
551
552     fn lorem(
553         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
554         adipiscing: Adipiscing, elit: Elit,
555     ) {
556         // body
557     }
558 }
559 ```
560
561 #### `"CompressedIfEmpty"`:
562
563 ```rust
564 trait Lorem {
565     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
566
567     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
568         // body
569     }
570
571     fn lorem(
572         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
573         adipiscing: Adipiscing, elit: Elit,
574     );
575
576     fn lorem(
577         ipsum: Ipsum,
578         dolor: Dolor,
579         sit: Sit,
580         amet: Amet,
581         consectetur: Consectetur,
582         adipiscing: Adipiscing,
583         elit: Elit,
584     ) {
585         // body
586     }
587 }
588 ```
589
590 #### `"Vertical"`:
591
592 ```rust
593 trait Lorem {
594     fn lorem(ipsum: Ipsum,
595              dolor: Dolor,
596              sit: Sit,
597              amet: Amet);
598
599     fn lorem(ipsum: Ipsum,
600              dolor: Dolor,
601              sit: Sit,
602              amet: Amet) {
603         // body
604     }
605
606     fn lorem(ipsum: Ipsum,
607              dolor: Dolor,
608              sit: Sit,
609              amet: Amet,
610              consectetur: Consectetur,
611              adipiscing: Adipiscing,
612              elit: Elit);
613
614     fn lorem(ipsum: Ipsum,
615              dolor: Dolor,
616              sit: Sit,
617              amet: Amet,
618              consectetur: Consectetur,
619              adipiscing: Adipiscing,
620              elit: Elit) {
621         // body
622     }
623 }
624 ```
625
626 ## `fn_args_indent`
627
628 Layout of function arguments and tuple structs
629
630 - **Default value**: `"Block"`
631 - **Possible values**: `"Block"`, `"Visual"`
632
633 #### `"Block"` (default):
634
635 ```rust
636 fn lorem() {}
637
638 fn lorem(ipsum: usize) {}
639
640 fn lorem(
641     ipsum: usize,
642     dolor: usize,
643     sit: usize,
644     amet: usize,
645     consectetur: usize,
646     adipiscing: usize,
647     elit: usize,
648 ) {
649     // body
650 }
651 ```
652
653 #### `"Visual"`:
654
655 ```rust
656 fn lorem() {}
657
658 fn lorem(ipsum: usize) {}
659
660 fn lorem(ipsum: usize,
661          dolor: usize,
662          sit: usize,
663          amet: usize,
664          consectetur: usize,
665          adipiscing: usize,
666          elit: usize) {
667     // body
668 }
669 ```
670
671 ## `fn_args_paren_newline`
672
673 If function argument parenthesis goes on a newline
674
675 - **Default value**: `false`
676 - **Possible values**: `true`, `false`
677
678 #### `false` (default):
679
680 ```rust
681 fn lorem(
682     ipsum: Ipsum,
683     dolor: Dolor,
684     sit: Sit,
685     amet: Amet,
686 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
687     // body
688 }
689 ```
690
691 #### `true`:
692
693 ```rust
694 fn lorem
695     (
696     ipsum: Ipsum,
697     dolor: Dolor,
698     sit: Sit,
699     amet: Amet,
700 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
701     // body
702 }
703 ```
704
705 ## `fn_brace_style`
706
707 Brace style for functions
708
709 - **Default value**: `"SameLineWhere"`
710 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
711
712 #### `"SameLineWhere"` (default):
713
714 ```rust
715 fn lorem() {
716     // body
717 }
718
719 fn lorem(ipsum: usize) {
720     // body
721 }
722
723 fn lorem<T>(ipsum: T)
724 where
725     T: Add + Sub + Mul + Div,
726 {
727     // body
728 }
729 ```
730
731 #### `"AlwaysNextLine"`:
732
733 ```rust
734 fn lorem()
735 {
736     // body
737 }
738
739 fn lorem(ipsum: usize)
740 {
741     // body
742 }
743
744 fn lorem<T>(ipsum: T)
745 where
746     T: Add + Sub + Mul + Div,
747 {
748     // body
749 }
750 ```
751
752 #### `"PreferSameLine"`:
753
754 ```rust
755 fn lorem() {
756     // body
757 }
758
759 fn lorem(ipsum: usize) {
760     // body
761 }
762
763 fn lorem<T>(ipsum: T)
764 where
765     T: Add + Sub + Mul + Div, {
766     // body
767 }
768 ```
769
770 ## `fn_call_indent`
771
772 Indentation for function calls, etc.
773
774 - **Default value**: `"Block"`
775 - **Possible values**: `"Block"`, `"Visual"`
776
777 #### `"Block"` (default):
778
779 ```rust
780 lorem(
781     "lorem",
782     "ipsum",
783     "dolor",
784     "sit",
785     "amet",
786     "consectetur",
787     "adipiscing",
788     "elit",
789 );
790 ```
791
792 #### `"Visual"`:
793
794 ```rust
795 lorem("lorem",
796       "ipsum",
797       "dolor",
798       "sit",
799       "amet",
800       "consectetur",
801       "adipiscing",
802       "elit");
803 ```
804
805 ## `fn_call_width`
806
807 Maximum width of the args of a function call before falling back to vertical formatting
808
809 - **Default value**: `60`
810 - **Possible values**: any positive integer
811
812 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
813
814 #### Function call shorter than `fn_call_width`:
815 ```rust
816 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
817 ```
818
819 #### Function call longer than `fn_call_width`:
820
821 See [`fn_call_indent`](#fn_call_indent).
822
823 ## `fn_empty_single_line`
824
825 Put empty-body functions on a single line
826
827 - **Default value**: `true`
828 - **Possible values**: `true`, `false`
829
830 #### `true` (default):
831
832 ```rust
833 fn lorem() {}
834 ```
835
836 #### `false`:
837
838 ```rust
839 fn lorem() {
840 }
841 ```
842
843 See also [`control_brace_style`](#control_brace_style).
844
845 ## `fn_return_indent`
846
847 Location of return type in function declaration
848
849 - **Default value**: `"WithArgs"`
850 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
851
852 #### `"WithArgs"` (default):
853
854 ```rust
855 fn lorem(ipsum: Ipsum,
856          dolor: Dolor,
857          sit: Sit,
858          amet: Amet,
859          consectetur: Consectetur,
860          adipiscing: Adipiscing)
861          -> Elit
862     where Ipsum: Eq
863 {
864     // body
865 }
866
867 ```
868
869 #### `"WithWhereClause"`:
870
871 ```rust
872 fn lorem(ipsum: Ipsum,
873          dolor: Dolor,
874          sit: Sit,
875          amet: Amet,
876          consectetur: Consectetur,
877          adipiscing: Adipiscing)
878     -> Elit
879     where Ipsum: Eq
880 {
881     // body
882 }
883
884 ```
885
886 **Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`.
887
888 ## `fn_single_line`
889
890 Put single-expression functions on a single line
891
892 - **Default value**: `false`
893 - **Possible values**: `true`, `false`
894
895 #### `false` (default):
896
897 ```rust
898 fn lorem() -> usize {
899     42
900 }
901
902 fn lorem() -> usize {
903     let ipsum = 42;
904     ipsum
905 }
906 ```
907
908 #### `true`:
909
910 ```rust
911 fn lorem() -> usize { 42 }
912
913 fn lorem() -> usize {
914     let ipsum = 42;
915     ipsum
916 }
917 ```
918
919 See also [`control_brace_style`](#control_brace_style).
920
921 ## `force_explicit_abi`
922
923 Always print the abi for extern items
924
925 - **Default value**: `true`
926 - **Possible values**: `true`, `false`
927
928 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
929
930 #### `true` (default):
931
932 ```rust
933 extern "C" {
934     pub static lorem: c_int;
935 }
936 ```
937
938 #### `false`:
939
940 ```rust
941 extern {
942     pub static lorem: c_int;
943 }
944 ```
945
946 ## `force_format_strings`
947
948 Always format string literals
949
950 - **Default value**: `false`
951 - **Possible values**: `true`, `false`
952
953 See [`format_strings`](#format_strings).
954
955 See also [`max_width`](#max_width).
956
957 ## `format_strings`
958
959 Format string literals where necessary
960
961 - **Default value**: `false`
962 - **Possible values**: `true`, `false`
963
964 #### `false` (default):
965
966 ```rust
967 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
968 ```
969
970 #### `true`:
971
972 ```rust
973 let lorem =
974     "ipsum dolor sit amet consectetur \
975      adipiscing elit lorem ipsum dolor sit";
976 ```
977
978 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
979
980 ## `generics_indent`
981
982 Indentation of generics
983
984 - **Default value**: `"Block"`
985 - **Possible values**: `"Block"`, `"Visual"`
986
987 #### `"Block"` (default):
988
989 ```rust
990 fn lorem<
991     Ipsum: Eq = usize,
992     Dolor: Eq = usize,
993     Sit: Eq = usize,
994     Amet: Eq = usize,
995     Adipiscing: Eq = usize,
996     Consectetur: Eq = usize,
997     Elit: Eq = usize
998 >(
999     ipsum: Ipsum,
1000     dolor: Dolor,
1001     sit: Sit,
1002     amet: Amet,
1003     adipiscing: Adipiscing,
1004     consectetur: Consectetur,
1005     elit: Elit,
1006 ) -> T {
1007     // body
1008 }
1009 ```
1010
1011 #### `"Visual"`:
1012
1013 ```rust
1014 fn lorem<Ipsum: Eq = usize,
1015          Dolor: Eq = usize,
1016          Sit: Eq = usize,
1017          Amet: Eq = usize,
1018          Adipiscing: Eq = usize,
1019          Consectetur: Eq = usize,
1020          Elit: Eq = usize>
1021     (ipsum: Ipsum,
1022      dolor: Dolor,
1023      sit: Sit,
1024      amet: Amet,
1025      adipiscing: Adipiscing,
1026      consectetur: Consectetur,
1027      elit: Elit)
1028      -> T {
1029     // body
1030 }
1031 ```
1032
1033 ## `hard_tabs`
1034
1035 Use tab characters for indentation, spaces for alignment
1036
1037 - **Default value**: `false`
1038 - **Possible values**: `true`, `false`
1039
1040 #### `false` (default):
1041
1042 ```rust
1043 fn lorem() -> usize {
1044     42 // spaces before 42
1045 }
1046 ```
1047
1048 #### `true`:
1049
1050 ```rust
1051 fn lorem() -> usize {
1052         42 // tabs before 42
1053 }
1054 ```
1055
1056 See also: [`tab_spaces`](#tab_spaces).
1057
1058 ## `impl_empty_single_line`
1059
1060 Put empty-body implementations on a single line
1061
1062 - **Default value**: `true`
1063 - **Possible values**: `true`, `false`
1064
1065 #### `true` (default):
1066
1067 ```rust
1068 impl Lorem {}
1069 ```
1070
1071 #### `false`:
1072
1073 ```rust
1074 impl Lorem {
1075 }
1076 ```
1077
1078 See also [`item_brace_style`](#item_brace_style).
1079
1080 ## `indent_match_arms`
1081
1082 Indent match arms instead of keeping them at the same indentation level as the match keyword
1083
1084 - **Default value**: `true`
1085 - **Possible values**: `true`, `false`
1086
1087 #### `true` (default):
1088
1089 ```rust
1090 match lorem {
1091     Lorem::Ipsum => (),
1092     Lorem::Dolor => (),
1093     Lorem::Sit => (),
1094     Lorem::Amet => (),
1095 }
1096 ```
1097
1098 #### `false`:
1099
1100 ```rust
1101 match lorem {
1102 Lorem::Ipsum => (),
1103 Lorem::Dolor => (),
1104 Lorem::Sit => (),
1105 Lorem::Amet => (),
1106 }
1107 ```
1108
1109 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1110
1111 ## `imports_indent`
1112
1113 Indent style of imports
1114
1115 - **Default Value**: `"Visual"`
1116 - **Possible values**: `"Block"`, `"Visual"`
1117
1118 #### `"Visual"` (default):
1119
1120 ```rust
1121 use foo::{xxx,
1122           yyy,
1123           zzz};
1124 ```
1125
1126 #### `"Block"`:
1127
1128 ```rust
1129 use foo::{
1130     xxx,
1131     yyy,
1132     zzz,
1133 };
1134 ```
1135
1136 See also: [`imports_layout`](#imports_layout).
1137
1138 ## `imports_layout`
1139
1140 Item layout inside a imports block
1141
1142 - **Default value**: "Mixed"
1143 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1144
1145 #### `"Mixed"` (default):
1146
1147 ```rust
1148 use foo::{xxx, yyy, zzz};
1149
1150 use foo::{aaa, bbb, ccc,
1151           ddd, eee, fff};
1152 ```
1153
1154 #### `"Horizontal"`:
1155
1156 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1157
1158 ```rust
1159 use foo::{xxx, yyy, zzz};
1160
1161 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1162 ```
1163
1164 #### `"HorizontalVertical"`:
1165
1166 ```rust
1167 use foo::{xxx, yyy, zzz};
1168
1169 use foo::{aaa,
1170           bbb,
1171           ccc,
1172           ddd,
1173           eee,
1174           fff};
1175 ```
1176
1177 #### `"Vertical"`:
1178
1179 ```rust
1180 use foo::{xxx,
1181           yyy,
1182           zzz};
1183
1184 use foo::{aaa,
1185           bbb,
1186           ccc,
1187           ddd,
1188           eee,
1189           fff};
1190 ```
1191
1192 ## `item_brace_style`
1193
1194 Brace style for structs and enums
1195
1196 - **Default value**: `"SameLineWhere"`
1197 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1198
1199 #### `"SameLineWhere"` (default):
1200
1201 ```rust
1202 struct Lorem {
1203     ipsum: bool,
1204 }
1205
1206 struct Dolor<T>
1207     where T: Eq
1208 {
1209     sit: T,
1210 }
1211 ```
1212
1213 #### `"AlwaysNextLine"`:
1214
1215 ```rust
1216 struct Lorem
1217 {
1218     ipsum: bool,
1219 }
1220
1221 struct Dolor<T>
1222     where T: Eq
1223 {
1224     sit: T,
1225 }
1226 ```
1227
1228 #### `"PreferSameLine"`:
1229
1230 ```rust
1231 struct Lorem {
1232     ipsum: bool,
1233 }
1234
1235 struct Dolor<T>
1236     where T: Eq {
1237     sit: T,
1238 }
1239 ```
1240
1241 ## `match_arm_forces_newline`
1242
1243 Consistently put match arms (block based or not) in a newline.
1244
1245 - **Default value**: `false`
1246 - **Possible values**: `true`, `false`
1247
1248 #### `false` (default):
1249
1250 ```rust
1251 match x {
1252     // a non-empty block
1253     X0 => {
1254         f();
1255     }
1256     // an empty block
1257     X1 => {}
1258     // a non-block
1259     X2 => println!("ok"),
1260 }
1261 ```
1262
1263 #### `true`:
1264
1265 ```rust
1266 match x {
1267     // a non-empty block
1268     X0 => {
1269         f();
1270     }
1271     // an empty block
1272     X1 =>
1273         {}
1274     // a non-block
1275     X2 => {
1276         println!("ok")
1277     }
1278 }
1279 ```
1280
1281 See also: [`wrap_match_arms`](#wrap_match_arms).
1282
1283 ## `match_block_trailing_comma`
1284
1285 Put a trailing comma after a block based match arm (non-block arms are not affected)
1286
1287 - **Default value**: `false`
1288 - **Possible values**: `true`, `false`
1289
1290 #### `false` (default):
1291
1292 ```rust
1293 match lorem {
1294     Lorem::Ipsum => {
1295         println!("ipsum");
1296     }
1297     Lorem::Dolor => println!("dolor"),
1298 }
1299 ```
1300
1301 #### `true`:
1302
1303 ```rust
1304 match lorem {
1305     Lorem::Ipsum => {
1306         println!("ipsum");
1307     },
1308     Lorem::Dolor => println!("dolor"),
1309 }
1310 ```
1311
1312 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1313
1314 ## `match_pattern_separator_break_point`
1315
1316 Put a match sub-patterns' separator (`|`) in front or back.
1317
1318 - **Default value**: `"Back"`
1319 - **Possible values**: `"Back"`, `"Front"`
1320
1321 #### `"Back"` (default):
1322
1323 ```rust
1324 match m {
1325     Variant::Tag |
1326     Variant::Tag2 |
1327     Variant::Tag3 |
1328     Variant::Tag4 |
1329     Variant::Tag5 |
1330     Variant::Tag6 => {}
1331 }
1332 ```
1333
1334 #### `Front`:
1335
1336 ```rust
1337 match m {
1338     Variant::Tag
1339     | Variant::Tag2
1340     | Variant::Tag3
1341     | Variant::Tag4
1342     | Variant::Tag5
1343     | Variant::Tag6 => {}
1344 }
1345 ```
1346
1347 ## `max_width`
1348
1349 Maximum width of each line
1350
1351 - **Default value**: `100`
1352 - **Possible values**: any positive integer
1353
1354 See also [`error_on_line_overflow`](#error_on_line_overflow).
1355
1356 ## `merge_derives`
1357
1358 Merge multiple derives into a single one.
1359
1360 - **Default value**: `true`
1361 - **Possible values**: `true`, `false`
1362
1363 #### `true` (default):
1364
1365 ```rust
1366 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1367 pub enum Foo {}
1368 ```
1369
1370 #### `false`:
1371
1372 ```rust
1373 #[derive(Eq, PartialEq)]
1374 #[derive(Debug)]
1375 #[derive(Copy, Clone)]
1376 pub enum Foo {}
1377 ```
1378
1379 ## `multiline_closure_forces_block`
1380
1381 Force multiline closure bodies to be wrapped in a block
1382
1383 - **Default value**: `false`
1384 - **Possible values**: `false`, `true`
1385
1386 #### `false` (default):
1387
1388 ```rust
1389 result.and_then(|maybe_value| match maybe_value {
1390     None => ...,
1391     Some(value) => ...,
1392 })
1393 ```
1394
1395 #### `true`:
1396
1397 ```rust
1398
1399 result.and_then(|maybe_value| {
1400     match maybe_value {
1401         None => ...,
1402         Some(value) => ...,
1403     }
1404 })
1405 ```
1406
1407 ## `multiline_match_arm_forces_block`
1408
1409 Force multiline match arm bodies to be wrapped in a block
1410
1411 - **Default value**: `false`
1412 - **Possible values**: `false`, `true`
1413
1414 #### `false` (default):
1415
1416 ```rust
1417 match lorem {
1418     None => if ipsum {
1419         println!("Hello World");
1420     },
1421     Some(dolor) => ...,
1422 }
1423 ```
1424
1425 #### `true`:
1426
1427 ```rust
1428 match lorem {
1429     None => {
1430         if ipsum {
1431             println!("Hello World");
1432         }
1433     }
1434     Some(dolor) => ...,
1435 }
1436 ```
1437
1438 ## `newline_style`
1439
1440 Unix or Windows line endings
1441
1442 - **Default value**: `"Unix"`
1443 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1444
1445 ## `normalize_comments`
1446
1447 Convert /* */ comments to // comments where possible
1448
1449 - **Default value**: `false`
1450 - **Possible values**: `true`, `false`
1451
1452 #### `false` (default):
1453
1454 ```rust
1455 // Lorem ipsum:
1456 fn dolor() -> usize {}
1457
1458 /* sit amet: */
1459 fn adipiscing() -> usize {}
1460 ```
1461
1462 #### `true`:
1463
1464 ```rust
1465 // Lorem ipsum:
1466 fn dolor() -> usize {}
1467
1468 // sit amet:
1469 fn adipiscing() -> usize {}
1470 ```
1471
1472 ## `reorder_imported_names`
1473
1474 Reorder lists of names in import statements alphabetically
1475
1476 - **Default value**: `false`
1477 - **Possible values**: `true`, `false`
1478
1479 #### `false` (default):
1480
1481 ```rust
1482 use super::{lorem, ipsum, dolor, sit};
1483 ```
1484
1485 #### `true`:
1486
1487 ```rust
1488 use super::{dolor, ipsum, lorem, sit};
1489 ```
1490
1491 See also [`reorder_imports`](#reorder_imports).
1492
1493 ## `reorder_imports`
1494
1495 Reorder import statements alphabetically
1496
1497 - **Default value**: `false`
1498 - **Possible values**: `true`, `false`
1499
1500 #### `false` (default):
1501
1502 ```rust
1503 use lorem;
1504 use ipsum;
1505 use dolor;
1506 use sit;
1507 ```
1508
1509 #### `true`:
1510
1511 ```rust
1512 use dolor;
1513 use ipsum;
1514 use lorem;
1515 use sit;
1516 ```
1517
1518 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1519
1520 ## `reorder_imports_in_group`
1521
1522 Reorder import statements in group
1523
1524 - **Default value**: `false`
1525 - **Possible values**: `true`, `false`
1526
1527 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1528
1529 #### `false` (default):
1530
1531 ```rust
1532 use std::mem;
1533 use std::io;
1534
1535 use lorem;
1536 use ipsum;
1537 use dolor;
1538 use sit;
1539 ```
1540
1541 #### `true`:
1542
1543 ```rust
1544 use std::io;
1545 use std::mem;
1546
1547 use dolor;
1548 use ipsum;
1549 use lorem;
1550 use sit;
1551 ```
1552
1553 See also [`reorder_imports`](#reorder_imports).
1554
1555 ## `single_line_if_else_max_width`
1556
1557 Maximum line length for single line if-else expressions.
1558
1559 - **Default value**: `50`
1560 - **Possible values**: any positive integer
1561
1562 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1563
1564 #### Lines shorter than `single_line_if_else_max_width`:
1565 ```rust
1566 let lorem = if ipsum { dolor } else { sit };
1567 ```
1568
1569 #### Lines longer than `single_line_if_else_max_width`:
1570 ```rust
1571 let lorem = if ipsum {
1572     dolor
1573 } else {
1574     sit
1575 };
1576 ```
1577
1578 See also: [`control_brace_style`](#control_brace_style).
1579
1580 ## `skip_children`
1581
1582 Don't reformat out of line modules
1583
1584 - **Default value**: `false`
1585 - **Possible values**: `true`, `false`
1586
1587 ## `space_after_bound_colon`
1588
1589 Leave a space after the colon in a trait or lifetime bound
1590
1591 - **Default value**: `true`
1592 - **Possible values**: `true`, `false`
1593
1594 #### `true` (default):
1595
1596 ```rust
1597 fn lorem<T: Eq>(t: T) {
1598     // body
1599 }
1600 ```
1601
1602 #### `false`:
1603
1604 ```rust
1605 fn lorem<T:Eq>(t: T) {
1606     // body
1607 }
1608 ```
1609
1610 See also: [`space_before_bound`](#space_before_bound).
1611
1612 ## `struct_field_align_threshold`
1613
1614 The maximum diff of width between struct fields to be aligned with each other.
1615
1616 - **Default value** : 0
1617 - **Possible values**: any positive integer
1618
1619 #### `0` (default):
1620
1621 ```rust
1622 struct Foo {
1623     x: u32,
1624     yy: u32,
1625     zzz: u32,
1626 }
1627 ```
1628
1629 #### `20`:
1630
1631 ```rust
1632 struct Foo {
1633     x:   u32,
1634     yy:  u32,
1635     zzz: u32,
1636 }
1637 ```
1638
1639 ## `space_after_struct_lit_field_colon`
1640
1641 Leave a space after the colon in a struct literal field
1642
1643 - **Default value**: `true`
1644 - **Possible values**: `true`, `false`
1645
1646 #### `true` (default):
1647
1648 ```rust
1649 let lorem = Lorem {
1650     ipsum: dolor,
1651     sit: amet,
1652 };
1653 ```
1654
1655 #### `false`:
1656
1657 ```rust
1658 let lorem = Lorem {
1659     ipsum:dolor,
1660     sit:amet,
1661 };
1662 ```
1663
1664 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1665
1666 ## `space_after_type_annotation_colon`
1667
1668 Leave a space after the colon in a type annotation
1669
1670 - **Default value**: `true`
1671 - **Possible values**: `true`, `false`
1672
1673 #### `true` (default):
1674
1675 ```rust
1676 fn lorem<T: Eq>(t: T) {
1677     let ipsum: Dolor = sit;
1678 }
1679 ```
1680
1681 #### `false`:
1682
1683 ```rust
1684 fn lorem<T: Eq>(t:T) {
1685     let ipsum:Dolor = sit;
1686 }
1687 ```
1688
1689 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1690
1691 ## `space_before_bound`
1692
1693 Leave a space before the colon in a trait or lifetime bound
1694
1695 - **Default value**: `false`
1696 - **Possible values**: `true`, `false`
1697
1698 #### `false` (default):
1699
1700 ```rust
1701 fn lorem<T: Eq>(t: T) {
1702     let ipsum: Dolor = sit;
1703 }
1704 ```
1705
1706 #### `true`:
1707
1708 ```rust
1709 fn lorem<T : Eq>(t: T) {
1710     let ipsum: Dolor = sit;
1711 }
1712 ```
1713
1714 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1715
1716 ## `space_before_struct_lit_field_colon`
1717
1718 Leave a space before the colon in a struct literal field
1719
1720 - **Default value**: `false`
1721 - **Possible values**: `true`, `false`
1722
1723 #### `false` (default):
1724
1725 ```rust
1726 let lorem = Lorem {
1727     ipsum: dolor,
1728     sit: amet,
1729 };
1730 ```
1731
1732 #### `true`:
1733
1734 ```rust
1735 let lorem = Lorem {
1736     ipsum : dolor,
1737     sit : amet,
1738 };
1739 ```
1740
1741 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1742
1743 ## `space_before_type_annotation`
1744
1745 Leave a space before the colon in a type annotation
1746
1747 - **Default value**: `false`
1748 - **Possible values**: `true`, `false`
1749
1750 #### `false` (default):
1751
1752 ```rust
1753 fn lorem<T: Eq>(t: T) {
1754     let ipsum: Dolor = sit;
1755 }
1756 ```
1757
1758 #### `true`:
1759
1760 ```rust
1761 fn lorem<T: Eq>(t : T) {
1762     let ipsum : Dolor = sit;
1763 }
1764 ```
1765
1766 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1767
1768 ## `spaces_around_ranges`
1769
1770 Put spaces around the .. and ... range operators
1771
1772 - **Default value**: `false`
1773 - **Possible values**: `true`, `false`
1774
1775 #### `false` (default):
1776
1777 ```rust
1778 let lorem = 0..10;
1779 ```
1780
1781 #### `true`:
1782
1783 ```rust
1784 let lorem = 0 .. 10;
1785 ```
1786
1787 ## `spaces_within_angle_brackets`
1788
1789 Put spaces within non-empty generic arguments
1790
1791 - **Default value**: `false`
1792 - **Possible values**: `true`, `false`
1793
1794 #### `false` (default):
1795
1796 ```rust
1797 fn lorem<T: Eq>(t: T) {
1798     // body
1799 }
1800 ```
1801
1802 #### `true`:
1803
1804 ```rust
1805 fn lorem< T: Eq >(t: T) {
1806     // body
1807 }
1808 ```
1809
1810 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1811
1812 ## `spaces_within_parens`
1813
1814 Put spaces within non-empty parentheses
1815
1816 - **Default value**: `false`
1817 - **Possible values**: `true`, `false`
1818
1819 #### `false` (default):
1820
1821 ```rust
1822 fn lorem<T: Eq>(t: T) {
1823     let lorem = (ipsum, dolor);
1824 }
1825 ```
1826
1827 #### `true`:
1828
1829 ```rust
1830 fn lorem<T: Eq>( t: T ) {
1831     let lorem = ( ipsum, dolor );
1832 }
1833 ```
1834
1835 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1836
1837 ## `spaces_within_square_brackets`
1838
1839 Put spaces within non-empty square brackets
1840
1841 - **Default value**: `false`
1842 - **Possible values**: `true`, `false`
1843
1844 #### `false` (default):
1845
1846 ```rust
1847 let lorem: [usize; 2] = [ipsum, dolor];
1848 ```
1849
1850 #### `true`:
1851
1852 ```rust
1853 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1854 ```
1855
1856 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1857
1858 ## `struct_lit_multiline_style`
1859
1860 Multiline style on literal structs
1861
1862 - **Default value**: `"PreferSingle"`
1863 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1864
1865 #### `"PreferSingle"` (default):
1866
1867 ```rust
1868 let lorem = Lorem { ipsum: dolor, sit: amet };
1869 ```
1870
1871 #### `"ForceMulti"`:
1872
1873 ```rust
1874 let lorem = Lorem {
1875     ipsum: dolor,
1876     sit: amet,
1877 };
1878 ```
1879
1880 See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width).
1881
1882 ## `struct_lit_indent`
1883
1884 Style of struct definition
1885
1886 - **Default value**: `"Block"`
1887 - **Possible values**: `"Block"`, `"Visual"`
1888
1889 #### `"Block"` (default):
1890
1891 ```rust
1892 let lorem = Lorem {
1893     ipsum: dolor,
1894     sit: amet,
1895 };
1896 ```
1897
1898 #### `"Visual"`:
1899
1900 ```rust
1901 let lorem = Lorem { ipsum: dolor,
1902                     sit: amet, };
1903 ```
1904
1905 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
1906
1907 ## `struct_lit_width`
1908
1909 Maximum width in the body of a struct lit before falling back to vertical formatting
1910
1911 - **Default value**: `18`
1912 - **Possible values**: any positive integer
1913
1914 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1915
1916 #### Lines shorter than `struct_lit_width`:
1917 ```rust
1918 let lorem = Lorem { ipsum: dolor, sit: amet };
1919 ```
1920
1921 #### Lines longer than `struct_lit_width`:
1922 See [`struct_lit_indent`](#struct_lit_indent).
1923
1924 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
1925
1926 ## `struct_variant_width`
1927
1928 Maximum width in the body of a struct variant before falling back to vertical formatting
1929
1930 - **Default value**: `35`
1931 - **Possible values**: any positive integer
1932
1933 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1934
1935 #### Struct variants shorter than `struct_variant_width`:
1936 ```rust
1937 enum Lorem {
1938     Ipsum,
1939     Dolor(bool),
1940     Sit { amet: Consectetur, adipiscing: Elit },
1941 }
1942 ```
1943
1944 #### Struct variants longer than `struct_variant_width`:
1945 ```rust
1946 enum Lorem {
1947     Ipsum,
1948     Dolor(bool),
1949     Sit {
1950         amet: Consectetur,
1951         adipiscing: Elit,
1952     },
1953 }
1954 ```
1955
1956 ## `tab_spaces`
1957
1958 Number of spaces per tab
1959
1960 - **Default value**: `4`
1961 - **Possible values**: any positive integer
1962
1963 #### `4` (default):
1964
1965 ```rust
1966 fn lorem() {
1967     let ipsum = dolor();
1968     let sit = vec![
1969         "amet consectetur adipiscing elit."
1970     ];
1971 }
1972 ```
1973
1974 #### `2`:
1975
1976 ```rust
1977 fn lorem() {
1978   let ipsum = dolor();
1979   let sit = vec![
1980     "amet consectetur adipiscing elit."
1981   ];
1982 }
1983 ```
1984
1985 See also: [`hard_tabs`](#hard_tabs).
1986
1987 ## `take_source_hints`
1988
1989 Retain some formatting characteristics from the source code
1990
1991 - **Default value**: `false`
1992 - **Possible values**: `true`, `false`
1993
1994 #### `false` (default):
1995
1996 ```rust
1997 lorem
1998     .ipsum()
1999     .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2000 ```
2001
2002 #### `true`:
2003
2004 ```rust
2005 lorem
2006     .ipsum()
2007     .dolor(|| {
2008                sit.amet()
2009                    .consectetur()
2010                    .adipiscing()
2011                    .elit();
2012            });
2013 ```
2014
2015 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2016
2017 ## `trailing_comma`
2018
2019 How to handle trailing commas for lists
2020
2021 - **Default value**: `"Vertical"`
2022 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2023
2024 #### `"Vertical"` (default):
2025
2026 ```rust
2027 let Lorem { ipsum, dolor, sit } = amet;
2028 let Lorem {
2029     ipsum,
2030     dolor,
2031     sit,
2032     amet,
2033     consectetur,
2034     adipiscing,
2035 } = elit;
2036 ```
2037
2038 #### `"Always"`:
2039
2040 ```rust
2041 let Lorem { ipsum, dolor, sit, } = amet;
2042 let Lorem {
2043     ipsum,
2044     dolor,
2045     sit,
2046     amet,
2047     consectetur,
2048     adipiscing,
2049 } = elit;
2050 ```
2051
2052 #### `"Never"`:
2053
2054 ```rust
2055 let Lorem { ipsum, dolor, sit } = amet;
2056 let Lorem {
2057     ipsum,
2058     dolor,
2059     sit,
2060     amet,
2061     consectetur,
2062     adipiscing
2063 } = elit;
2064 ```
2065
2066 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2067
2068 ## `trailing_semicolon`
2069
2070 Add trailing semicolon after break, continue and return
2071
2072 - **Default value**: `true`
2073 - **Possible values**: `true`, `false`
2074
2075 #### `true` (default):
2076 ```rust
2077 fn foo() -> usize {
2078     return 0;
2079 }
2080 ```
2081
2082 #### `false`:
2083 ```rust
2084 fn foo() -> usize {
2085     return 0
2086 }
2087 ```
2088
2089 ## `type_punctuation_density`
2090
2091 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2092
2093 - **Default value**: `"Wide"`
2094 - **Possible values**: `"Compressed"`, `"Wide"`
2095
2096 #### `"Wide"` (default):
2097
2098 ```rust
2099 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2100         // body
2101 }
2102 ```
2103
2104 #### `"Compressed"`:
2105
2106 ```rust
2107 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2108         // body
2109 }
2110 ```
2111
2112 ## `use_try_shorthand`
2113
2114 Replace uses of the try! macro by the ? shorthand
2115
2116 - **Default value**: `false`
2117 - **Possible values**: `true`, `false`
2118
2119 #### `false` (default):
2120
2121 ```rust
2122 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2123 ```
2124
2125 #### `true`:
2126
2127 ```rust
2128 let lorem = ipsum.map(|dolor| dolor.sit())?;
2129 ```
2130
2131 ## `where_density`
2132
2133 Density of a where clause.
2134
2135 - **Default value**: `"Vertical"`
2136 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2137
2138 #### `"Vertical"` (default):
2139
2140 ```rust
2141 trait Lorem {
2142     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2143         where Dolor: Eq;
2144
2145     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2146         where Dolor: Eq
2147     {
2148         // body
2149     }
2150 }
2151 ```
2152
2153 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2154
2155 #### `"CompressedIfEmpty"`:
2156
2157 ```rust
2158 trait Lorem {
2159     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2160     where Dolor: Eq;
2161
2162     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2163     where
2164         Dolor: Eq,
2165     {
2166         // body
2167     }
2168 }
2169 ```
2170
2171 #### `"Compressed"`:
2172
2173 ```rust
2174 trait Lorem {
2175     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2176     where Dolor: Eq;
2177
2178     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2179     where Dolor: Eq {
2180         // body
2181     }
2182 }
2183 ```
2184
2185 #### `"Tall"`:
2186
2187 ```rust
2188 trait Lorem {
2189     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2190     where
2191         Dolor: Eq;
2192
2193     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2194     where
2195         Dolor: Eq,
2196     {
2197         // body
2198     }
2199 }
2200 ```
2201
2202 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2203
2204 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2205
2206 ## `where_layout`
2207
2208 Element layout inside a where clause
2209
2210 - **Default value**: `"Vertical"`
2211 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2212
2213 #### `"Vertical"` (default):
2214
2215 ```rust
2216 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2217     where Ipsum: IpsumDolorSitAmet,
2218           Dolor: DolorSitAmetConsectetur
2219 {
2220     // body
2221 }
2222
2223 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2224     where Ipsum: IpsumDolorSitAmet,
2225           Dolor: DolorSitAmetConsectetur,
2226           Sit: SitAmetConsecteturAdipiscing,
2227           Amet: AmetConsecteturAdipiscingElit
2228 {
2229     // body
2230 }
2231 ```
2232
2233 #### `"Horizontal"`:
2234
2235 ```rust
2236 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2237     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2238 {
2239     // body
2240 }
2241
2242 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2243     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2244 {
2245     // body
2246 }
2247 ```
2248
2249 #### `"HorizontalVertical"`:
2250
2251 ```rust
2252 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2253     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2254 {
2255     // body
2256 }
2257
2258 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2259     where Ipsum: IpsumDolorSitAmet,
2260           Dolor: DolorSitAmetConsectetur,
2261           Sit: SitAmetConsecteturAdipiscing,
2262           Amet: AmetConsecteturAdipiscingElit
2263 {
2264     // body
2265 }
2266 ```
2267
2268 #### `"Mixed"`:
2269
2270 ```rust
2271 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2272     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2273 {
2274     // body
2275 }
2276
2277 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2278     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2279           Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2280 {
2281     // body
2282 }
2283 ```
2284
2285 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2286
2287 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2288
2289 ## `where_pred_indent`
2290
2291 Indentation style of a where predicate
2292
2293 - **Default value**: `"Visual"`
2294 - **Possible values**: `"Block"`, `"Visual"`
2295
2296 #### `"Visual"` (default):
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 #### `"Block"`:
2310
2311 ```rust
2312 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2313     where Ipsum: Eq,
2314         Dolor: Eq,
2315         Sit: Eq,
2316         Amet: Eq
2317 {
2318     // body
2319 }
2320 ```
2321
2322 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2323
2324 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2325
2326 ## `where_style`
2327
2328 Overall strategy for where clauses
2329
2330 - **Default value**: `"Rfc"`
2331 - **Possible values**: `"Rfc"`, `"Legacy"`
2332
2333 #### `"Rfc"` (default):
2334
2335 ```rust
2336 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2337 where
2338     Ipsum: Eq,
2339     Dolor: Eq,
2340     Sit: Eq,
2341     Amet: Eq,
2342 {
2343     // body
2344 }
2345 ```
2346
2347 #### `"Legacy"`:
2348
2349 ```rust
2350 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2351     where Ipsum: Eq,
2352           Dolor: Eq,
2353           Sit: Eq,
2354           Amet: Eq
2355 {
2356     // body
2357 }
2358 ```
2359
2360 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2361
2362 ## `wrap_comments`
2363
2364 Break comments to fit on the line
2365
2366 - **Default value**: `false`
2367 - **Possible values**: `true`, `false`
2368
2369 #### `false` (default):
2370
2371 ```rust
2372 // 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.
2373 ```
2374
2375 #### `true`:
2376
2377 ```rust
2378 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2379 // sed do eiusmod tempor incididunt ut labore et dolore
2380 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2381 // exercitation ullamco laboris nisi ut aliquip ex ea
2382 // commodo consequat.
2383 ```
2384
2385 ## `wrap_match_arms`
2386
2387 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2388
2389 - **Default value**: `true`
2390 - **Possible values**: `true`, `false`
2391
2392 #### `true` (default):
2393
2394 ```rust
2395 match lorem {
2396     true => {
2397         foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2398     }
2399     false => println!("{}", sit),
2400 }
2401 ```
2402
2403 #### `false`:
2404
2405 ```rust
2406 match lorem {
2407     true =>
2408         foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2409     false => println!("{}", sit),
2410 }
2411 ```
2412
2413 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2414
2415 ## `write_mode`
2416
2417 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2418
2419 - **Default value**: `"Overwrite"`
2420 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`