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