]> git.lizzy.rs Git - rust.git/blob - Configurations.md
Merge pull request #2148 from topecongiro/audit-option/brace_style
[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_bound_colon`
1723
1724 Leave a space after the colon in a trait or lifetime bound
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     // body
1734 }
1735 ```
1736
1737 #### `false`:
1738
1739 ```rust
1740 fn lorem<T:Eq>(t: T) {
1741     // body
1742 }
1743 ```
1744
1745 See also: [`space_before_bound`](#space_before_bound).
1746
1747 ## `struct_field_align_threshold`
1748
1749 The maximum diff of width between struct fields to be aligned with each other.
1750
1751 - **Default value** : 0
1752 - **Possible values**: any positive integer
1753
1754 #### `0` (default):
1755
1756 ```rust
1757 struct Foo {
1758     x: u32,
1759     yy: u32,
1760     zzz: u32,
1761 }
1762 ```
1763
1764 #### `20`:
1765
1766 ```rust
1767 struct Foo {
1768     x:   u32,
1769     yy:  u32,
1770     zzz: u32,
1771 }
1772 ```
1773
1774 ## `space_after_struct_lit_field_colon`
1775
1776 Leave a space after the colon in a struct literal field
1777
1778 - **Default value**: `true`
1779 - **Possible values**: `true`, `false`
1780
1781 #### `true` (default):
1782
1783 ```rust
1784 let lorem = Lorem {
1785     ipsum: dolor,
1786     sit: amet,
1787 };
1788 ```
1789
1790 #### `false`:
1791
1792 ```rust
1793 let lorem = Lorem {
1794     ipsum:dolor,
1795     sit:amet,
1796 };
1797 ```
1798
1799 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1800
1801 ## `space_after_type_annotation_colon`
1802
1803 Leave a space after the colon in a type annotation
1804
1805 - **Default value**: `true`
1806 - **Possible values**: `true`, `false`
1807
1808 #### `true` (default):
1809
1810 ```rust
1811 fn lorem<T: Eq>(t: T) {
1812     let ipsum: Dolor = sit;
1813 }
1814 ```
1815
1816 #### `false`:
1817
1818 ```rust
1819 fn lorem<T: Eq>(t:T) {
1820     let ipsum:Dolor = sit;
1821 }
1822 ```
1823
1824 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1825
1826 ## `space_before_bound`
1827
1828 Leave a space before the colon in a trait or lifetime bound
1829
1830 - **Default value**: `false`
1831 - **Possible values**: `true`, `false`
1832
1833 #### `false` (default):
1834
1835 ```rust
1836 fn lorem<T: Eq>(t: T) {
1837     let ipsum: Dolor = sit;
1838 }
1839 ```
1840
1841 #### `true`:
1842
1843 ```rust
1844 fn lorem<T : Eq>(t: T) {
1845     let ipsum: Dolor = sit;
1846 }
1847 ```
1848
1849 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1850
1851 ## `space_before_struct_lit_field_colon`
1852
1853 Leave a space before the colon in a struct literal field
1854
1855 - **Default value**: `false`
1856 - **Possible values**: `true`, `false`
1857
1858 #### `false` (default):
1859
1860 ```rust
1861 let lorem = Lorem {
1862     ipsum: dolor,
1863     sit: amet,
1864 };
1865 ```
1866
1867 #### `true`:
1868
1869 ```rust
1870 let lorem = Lorem {
1871     ipsum : dolor,
1872     sit : amet,
1873 };
1874 ```
1875
1876 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1877
1878 ## `space_before_type_annotation`
1879
1880 Leave a space before the colon in a type annotation
1881
1882 - **Default value**: `false`
1883 - **Possible values**: `true`, `false`
1884
1885 #### `false` (default):
1886
1887 ```rust
1888 fn lorem<T: Eq>(t: T) {
1889     let ipsum: Dolor = sit;
1890 }
1891 ```
1892
1893 #### `true`:
1894
1895 ```rust
1896 fn lorem<T: Eq>(t : T) {
1897     let ipsum : Dolor = sit;
1898 }
1899 ```
1900
1901 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1902
1903 ## `spaces_around_ranges`
1904
1905 Put spaces around the .. and ... range operators
1906
1907 - **Default value**: `false`
1908 - **Possible values**: `true`, `false`
1909
1910 #### `false` (default):
1911
1912 ```rust
1913 let lorem = 0..10;
1914 ```
1915
1916 #### `true`:
1917
1918 ```rust
1919 let lorem = 0 .. 10;
1920 ```
1921
1922 ## `spaces_within_angle_brackets`
1923
1924 Put spaces within non-empty generic arguments
1925
1926 - **Default value**: `false`
1927 - **Possible values**: `true`, `false`
1928
1929 #### `false` (default):
1930
1931 ```rust
1932 fn lorem<T: Eq>(t: T) {
1933     // body
1934 }
1935 ```
1936
1937 #### `true`:
1938
1939 ```rust
1940 fn lorem< T: Eq >(t: T) {
1941     // body
1942 }
1943 ```
1944
1945 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1946
1947 ## `spaces_within_parens`
1948
1949 Put spaces within non-empty parentheses
1950
1951 - **Default value**: `false`
1952 - **Possible values**: `true`, `false`
1953
1954 #### `false` (default):
1955
1956 ```rust
1957 fn lorem<T: Eq>(t: T) {
1958     let lorem = (ipsum, dolor);
1959 }
1960 ```
1961
1962 #### `true`:
1963
1964 ```rust
1965 fn lorem<T: Eq>( t: T ) {
1966     let lorem = ( ipsum, dolor );
1967 }
1968 ```
1969
1970 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1971
1972 ## `spaces_within_square_brackets`
1973
1974 Put spaces within non-empty square brackets
1975
1976 - **Default value**: `false`
1977 - **Possible values**: `true`, `false`
1978
1979 #### `false` (default):
1980
1981 ```rust
1982 let lorem: [usize; 2] = [ipsum, dolor];
1983 ```
1984
1985 #### `true`:
1986
1987 ```rust
1988 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1989 ```
1990
1991 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1992
1993 ## `struct_lit_multiline_style`
1994
1995 Multiline style on literal structs
1996
1997 - **Default value**: `"PreferSingle"`
1998 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1999
2000 #### `"PreferSingle"` (default):
2001
2002 ```rust
2003 let lorem = Lorem { ipsum: dolor, sit: amet };
2004 ```
2005
2006 #### `"ForceMulti"`:
2007
2008 ```rust
2009 let lorem = Lorem {
2010     ipsum: dolor,
2011     sit: amet,
2012 };
2013 ```
2014
2015 See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
2016
2017 ## `struct_lit_width`
2018
2019 Maximum width in the body of a struct lit before falling back to vertical formatting
2020
2021 - **Default value**: `18`
2022 - **Possible values**: any positive integer
2023
2024 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2025
2026 #### Lines shorter than `struct_lit_width`:
2027 ```rust
2028 let lorem = Lorem { ipsum: dolor, sit: amet };
2029 ```
2030
2031 #### Lines longer than `struct_lit_width`:
2032 See [`indent_style`](#indent_style).
2033
2034 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
2035
2036 ## `struct_variant_width`
2037
2038 Maximum width in the body of a struct variant before falling back to vertical formatting
2039
2040 - **Default value**: `35`
2041 - **Possible values**: any positive integer
2042
2043 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2044
2045 #### Struct variants shorter than `struct_variant_width`:
2046 ```rust
2047 enum Lorem {
2048     Ipsum,
2049     Dolor(bool),
2050     Sit { amet: Consectetur, adipiscing: Elit },
2051 }
2052 ```
2053
2054 #### Struct variants longer than `struct_variant_width`:
2055 ```rust
2056 enum Lorem {
2057     Ipsum,
2058     Dolor(bool),
2059     Sit {
2060         amet: Consectetur,
2061         adipiscing: Elit,
2062     },
2063 }
2064 ```
2065
2066 ## `tab_spaces`
2067
2068 Number of spaces per tab
2069
2070 - **Default value**: `4`
2071 - **Possible values**: any positive integer
2072
2073 #### `4` (default):
2074
2075 ```rust
2076 fn lorem() {
2077     let ipsum = dolor();
2078     let sit = vec![
2079         "amet consectetur adipiscing elit."
2080     ];
2081 }
2082 ```
2083
2084 #### `2`:
2085
2086 ```rust
2087 fn lorem() {
2088   let ipsum = dolor();
2089   let sit = vec![
2090     "amet consectetur adipiscing elit."
2091   ];
2092 }
2093 ```
2094
2095 See also: [`hard_tabs`](#hard_tabs).
2096
2097 ## `take_source_hints`
2098
2099 Retain some formatting characteristics from the source code
2100
2101 - **Default value**: `false`
2102 - **Possible values**: `true`, `false`
2103
2104 #### `false` (default):
2105
2106 ```rust
2107 lorem
2108     .ipsum()
2109     .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2110 ```
2111
2112 #### `true`:
2113
2114 ```rust
2115 lorem
2116     .ipsum()
2117     .dolor(|| {
2118                sit.amet()
2119                    .consectetur()
2120                    .adipiscing()
2121                    .elit();
2122            });
2123 ```
2124
2125 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2126
2127 ## `trailing_comma`
2128
2129 How to handle trailing commas for lists
2130
2131 - **Default value**: `"Vertical"`
2132 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2133
2134 #### `"Vertical"` (default):
2135
2136 ```rust
2137 let Lorem { ipsum, dolor, sit } = amet;
2138 let Lorem {
2139     ipsum,
2140     dolor,
2141     sit,
2142     amet,
2143     consectetur,
2144     adipiscing,
2145 } = elit;
2146 ```
2147
2148 #### `"Always"`:
2149
2150 ```rust
2151 let Lorem { ipsum, dolor, sit, } = amet;
2152 let Lorem {
2153     ipsum,
2154     dolor,
2155     sit,
2156     amet,
2157     consectetur,
2158     adipiscing,
2159 } = elit;
2160 ```
2161
2162 #### `"Never"`:
2163
2164 ```rust
2165 let Lorem { ipsum, dolor, sit } = amet;
2166 let Lorem {
2167     ipsum,
2168     dolor,
2169     sit,
2170     amet,
2171     consectetur,
2172     adipiscing
2173 } = elit;
2174 ```
2175
2176 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2177
2178 ## `trailing_semicolon`
2179
2180 Add trailing semicolon after break, continue and return
2181
2182 - **Default value**: `true`
2183 - **Possible values**: `true`, `false`
2184
2185 #### `true` (default):
2186 ```rust
2187 fn foo() -> usize {
2188     return 0;
2189 }
2190 ```
2191
2192 #### `false`:
2193 ```rust
2194 fn foo() -> usize {
2195     return 0
2196 }
2197 ```
2198
2199 ## `type_punctuation_density`
2200
2201 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2202
2203 - **Default value**: `"Wide"`
2204 - **Possible values**: `"Compressed"`, `"Wide"`
2205
2206 #### `"Wide"` (default):
2207
2208 ```rust
2209 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2210         // body
2211 }
2212 ```
2213
2214 #### `"Compressed"`:
2215
2216 ```rust
2217 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2218         // body
2219 }
2220 ```
2221
2222 ## `use_try_shorthand`
2223
2224 Replace uses of the try! macro by the ? shorthand
2225
2226 - **Default value**: `false`
2227 - **Possible values**: `true`, `false`
2228
2229 #### `false` (default):
2230
2231 ```rust
2232 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2233 ```
2234
2235 #### `true`:
2236
2237 ```rust
2238 let lorem = ipsum.map(|dolor| dolor.sit())?;
2239 ```
2240
2241 ## `where_density`
2242
2243 Density of a where clause.
2244
2245 - **Default value**: `"Vertical"`
2246 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2247
2248 #### `"Vertical"` (default):
2249
2250 ```rust
2251 trait Lorem {
2252     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2253     where
2254         Dolor: Eq;
2255
2256     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2257     where
2258         Dolor: Eq,
2259     {
2260         // body
2261     }
2262 }
2263 ```
2264
2265 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2266
2267 #### `"CompressedIfEmpty"`:
2268
2269 ```rust
2270 trait Lorem {
2271     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2272     where Dolor: Eq;
2273
2274     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2275     where
2276         Dolor: Eq,
2277     {
2278         // body
2279     }
2280 }
2281 ```
2282
2283 #### `"Compressed"`:
2284
2285 ```rust
2286 trait Lorem {
2287     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2288     where Dolor: Eq;
2289
2290     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2291     where Dolor: Eq {
2292         // body
2293     }
2294 }
2295 ```
2296
2297 #### `"Tall"`:
2298
2299 ```rust
2300 trait Lorem {
2301     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2302     where
2303         Dolor: Eq;
2304
2305     fn ipsum<Dolor>(dolor: Dolor) -> Sit
2306     where
2307         Dolor: Eq,
2308     {
2309         // body
2310     }
2311 }
2312 ```
2313
2314 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2315
2316 See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
2317
2318 ## `where_layout`
2319
2320 Element layout inside a where clause
2321
2322 - **Default value**: `"Vertical"`
2323 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2324
2325 #### `"Vertical"` (default):
2326
2327 ```rust
2328 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2329     where Ipsum: IpsumDolorSitAmet,
2330           Dolor: DolorSitAmetConsectetur
2331 {
2332     // body
2333 }
2334
2335 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2336     where Ipsum: IpsumDolorSitAmet,
2337           Dolor: DolorSitAmetConsectetur,
2338           Sit: SitAmetConsecteturAdipiscing,
2339           Amet: AmetConsecteturAdipiscingElit
2340 {
2341     // body
2342 }
2343 ```
2344
2345 #### `"Horizontal"`:
2346
2347 ```rust
2348 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2349     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2350 {
2351     // body
2352 }
2353
2354 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2355     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2356 {
2357     // body
2358 }
2359 ```
2360
2361 #### `"HorizontalVertical"`:
2362
2363 ```rust
2364 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2365     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2366 {
2367     // body
2368 }
2369
2370 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2371     where Ipsum: IpsumDolorSitAmet,
2372           Dolor: DolorSitAmetConsectetur,
2373           Sit: SitAmetConsecteturAdipiscing,
2374           Amet: AmetConsecteturAdipiscingElit
2375 {
2376     // body
2377 }
2378 ```
2379
2380 #### `"Mixed"`:
2381
2382 ```rust
2383 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2384     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2385 {
2386     // body
2387 }
2388
2389 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2390     where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2391           Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2392 {
2393     // body
2394 }
2395 ```
2396
2397 See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
2398
2399 ## `wrap_comments`
2400
2401 Break comments to fit on the line
2402
2403 - **Default value**: `false`
2404 - **Possible values**: `true`, `false`
2405
2406 #### `false` (default):
2407
2408 ```rust
2409 // 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.
2410 ```
2411
2412 #### `true`:
2413
2414 ```rust
2415 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2416 // sed do eiusmod tempor incididunt ut labore et dolore
2417 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2418 // exercitation ullamco laboris nisi ut aliquip ex ea
2419 // commodo consequat.
2420 ```
2421
2422 ## `wrap_match_arms`
2423
2424 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2425
2426 - **Default value**: `true`
2427 - **Possible values**: `true`, `false`
2428
2429 #### `true` (default):
2430
2431 ```rust
2432 match lorem {
2433     true => {
2434         foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2435     }
2436     false => println!("{}", sit),
2437 }
2438 ```
2439
2440 #### `false`:
2441
2442 ```rust
2443 match lorem {
2444     true =>
2445         foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2446     false => println!("{}", sit),
2447 }
2448 ```
2449
2450 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2451
2452 ## `write_mode`
2453
2454 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2455
2456 - **Default value**: `"Overwrite"`
2457 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`