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