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