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