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