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