]> git.lizzy.rs Git - rust.git/blob - Configurations.md
13c7acaed4f141f3266b9167710fa7d7d1263189
[rust.git] / Configurations.md
1 # Configuring Rustfmt
2
3 Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file.
4
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
6
7 ```toml
8 indent_style = "Block"
9 reorder_imported_names = true
10 ```
11
12 Each configuration option is either stable or unstable.
13 Stable options can be used directly, while unstable options are opt-in.
14 To enable unstable options, set `unstable_features = true` in `rustfmt.toml` or pass `--unstable-features` to rustfmt.
15
16 # Configuration Options
17
18 Below you find a detailed visual guide on all the supported configuration options of rustfmt:
19
20
21 ## `indent_style`
22
23 Indent on expressions or items.
24
25 - **Default value**: `"Block"`
26 - **Possible values**: `"Block"`, `"Visual"`
27 - **Stable**: No
28
29 ### Array
30
31 #### `"Block"` (default):
32
33 ```rust
34 fn main() {
35     let lorem = vec![
36         "ipsum",
37         "dolor",
38         "sit",
39         "amet",
40         "consectetur",
41         "adipiscing",
42         "elit",
43     ];
44 }
45 ```
46
47 #### `"Visual"`:
48
49 ```rust
50 fn main() {
51     let lorem = vec!["ipsum",
52                      "dolor",
53                      "sit",
54                      "amet",
55                      "consectetur",
56                      "adipiscing",
57                      "elit"];
58 }
59 ```
60
61 ### Control flow
62
63 #### `"Block"` (default):
64
65 ```rust
66 fn main() {
67     if lorem_ipsum && dolor_sit && amet_consectetur && lorem_sit && dolor_consectetur && amet_ipsum
68         && lorem_consectetur
69     {
70         // ...
71     }
72 }
73 ```
74
75 #### `"Visual"`:
76
77 ```rust
78 fn main() {
79     if lorem_ipsum && dolor_sit && amet_consectetur && lorem_sit && dolor_consectetur && amet_ipsum
80        && lorem_consectetur
81     {
82         // ...
83     }
84 }
85 ```
86
87 See also: [`control_brace_style`](#control_brace_style).
88
89 ### Function arguments
90
91 #### `"Block"` (default):
92
93 ```rust
94 fn lorem() {}
95
96 fn lorem(ipsum: usize) {}
97
98 fn lorem(
99     ipsum: usize,
100     dolor: usize,
101     sit: usize,
102     amet: usize,
103     consectetur: usize,
104     adipiscing: usize,
105     elit: usize,
106 ) {
107     // body
108 }
109 ```
110
111 #### `"Visual"`:
112
113 ```rust
114 fn lorem() {}
115
116 fn lorem(ipsum: usize) {}
117
118 fn lorem(ipsum: usize,
119          dolor: usize,
120          sit: usize,
121          amet: usize,
122          consectetur: usize,
123          adipiscing: usize,
124          elit: usize) {
125     // body
126 }
127 ```
128
129 ### Function calls
130
131 #### `"Block"` (default):
132
133 ```rust
134 fn main() {
135     lorem(
136         "lorem",
137         "ipsum",
138         "dolor",
139         "sit",
140         "amet",
141         "consectetur",
142         "adipiscing",
143         "elit",
144     );
145 }
146 ```
147
148 #### `"Visual"`:
149
150 ```rust
151 fn main() {
152     lorem("lorem",
153           "ipsum",
154           "dolor",
155           "sit",
156           "amet",
157           "consectetur",
158           "adipiscing",
159           "elit");
160 }
161 ```
162
163 ### Generics
164
165 #### `"Block"` (default):
166
167 ```rust
168 fn lorem<
169     Ipsum: Eq = usize,
170     Dolor: Eq = usize,
171     Sit: Eq = usize,
172     Amet: Eq = usize,
173     Adipiscing: Eq = usize,
174     Consectetur: Eq = usize,
175     Elit: Eq = usize,
176 >(
177     ipsum: Ipsum,
178     dolor: Dolor,
179     sit: Sit,
180     amet: Amet,
181     adipiscing: Adipiscing,
182     consectetur: Consectetur,
183     elit: Elit,
184 ) -> T {
185     // body
186 }
187 ```
188
189 #### `"Visual"`:
190
191 ```rust
192 fn lorem<Ipsum: Eq = usize,
193          Dolor: Eq = usize,
194          Sit: Eq = usize,
195          Amet: Eq = usize,
196          Adipiscing: Eq = usize,
197          Consectetur: Eq = usize,
198          Elit: Eq = usize>(
199     ipsum: Ipsum,
200     dolor: Dolor,
201     sit: Sit,
202     amet: Amet,
203     adipiscing: Adipiscing,
204     consectetur: Consectetur,
205     elit: Elit)
206     -> T {
207     // body
208 }
209 ```
210
211 #### Struct
212
213 #### `"Block"` (default):
214
215 ```rust
216 fn main() {
217     let lorem = Lorem {
218         ipsum: dolor,
219         sit: amet,
220     };
221 }
222 ```
223
224 #### `"Visual"`:
225
226 ```rust
227 fn main() {
228     let lorem = Lorem { ipsum: dolor,
229                         sit: amet, };
230 }
231 ```
232
233 See also: [`struct_lit_single_line`](#struct_lit_single_line), [`indent_style`](#indent_style).
234
235 ### Where predicates
236
237 #### `"Block"` (default):
238
239 ```rust
240 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
241 where
242     Ipsum: Eq,
243     Dolor: Eq,
244     Sit: Eq,
245     Amet: Eq,
246 {
247     // body
248 }
249 ```
250
251 #### `"Visual"`:
252
253 ```rust
254 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
255     where Ipsum: Eq,
256           Dolor: Eq,
257           Sit: Eq,
258           Amet: Eq
259 {
260     // body
261 }
262 ```
263
264 ## `use_small_heuristics`
265
266 Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'.
267
268 - **Default value**: `true`
269 - **Possible values**: `true`, `false`
270 - **Stable**: No
271
272 #### `true` (default):
273
274 ```rust
275 enum Lorem {
276     Ipsum,
277     Dolor(bool),
278     Sit { amet: Consectetur, adipiscing: Elit },
279 }
280
281 fn main() {
282     lorem(
283         "lorem",
284         "ipsum",
285         "dolor",
286         "sit",
287         "amet",
288         "consectetur",
289         "adipiscing",
290     );
291
292     let lorem = Lorem {
293         ipsum: dolor,
294         sit: amet,
295     };
296     let lorem = Lorem { ipsum: dolor };
297
298     let lorem = if ipsum { dolor } else { sit };
299 }
300 ```
301
302 #### `false`:
303
304 ```rust
305 enum Lorem {
306     Ipsum,
307     Dolor(bool),
308     Sit {
309         amet: Consectetur,
310         adipiscing: Elit,
311     },
312 }
313
314 fn main() {
315     lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing");
316
317     let lorem = Lorem {
318         ipsum: dolor,
319         sit: amet,
320     };
321
322     let lorem = if ipsum {
323         dolor
324     } else {
325         sit
326     };
327 }
328 ```
329
330 ## `binop_separator`
331
332 Where to put a binary operator when a binary expression goes multiline.
333
334 - **Default value**: `"Front"`
335 - **Possible values**: `"Front"`, `"Back"`
336 - **Stable**: No
337
338 #### `"Front"` (default):
339
340 ```rust
341 fn main() {
342     let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo
343         || barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
344
345     let sum = 123456789012345678901234567890 + 123456789012345678901234567890
346         + 123456789012345678901234567890;
347
348     let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
349         ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
350 }
351 ```
352
353 #### `"Back"`:
354
355 ```rust
356 fn main() {
357     let or = foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo ||
358         barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar;
359
360     let sum = 123456789012345678901234567890 + 123456789012345678901234567890 +
361         123456789012345678901234567890;
362
363     let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
364         bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
365 }
366 ```
367
368 ## `combine_control_expr`
369
370 Combine control expressions with function calls.
371
372 - **Default value**: `true`
373 - **Possible values**: `true`, `false`
374 - **Stable**: No
375
376 #### `true` (default):
377
378 ```rust
379 fn example() {
380     // If
381     foo!(if x {
382         foo();
383     } else {
384         bar();
385     });
386
387     // IfLet
388     foo!(if let Some(..) = x {
389         foo();
390     } else {
391         bar();
392     });
393
394     // While
395     foo!(while x {
396         foo();
397         bar();
398     });
399
400     // WhileLet
401     foo!(while let Some(..) = x {
402         foo();
403         bar();
404     });
405
406     // ForLoop
407     foo!(for x in y {
408         foo();
409         bar();
410     });
411
412     // Loop
413     foo!(loop {
414         foo();
415         bar();
416     });
417 }
418 ```
419
420 #### `false`:
421
422 ```rust
423 fn example() {
424     // If
425     foo!(
426         if x {
427             foo();
428         } else {
429             bar();
430         }
431     );
432
433     // IfLet
434     foo!(
435         if let Some(..) = x {
436             foo();
437         } else {
438             bar();
439         }
440     );
441
442     // While
443     foo!(
444         while x {
445             foo();
446             bar();
447         }
448     );
449
450     // WhileLet
451     foo!(
452         while let Some(..) = x {
453             foo();
454             bar();
455         }
456     );
457
458     // ForLoop
459     foo!(
460         for x in y {
461             foo();
462             bar();
463         }
464     );
465
466     // Loop
467     foo!(
468         loop {
469             foo();
470             bar();
471         }
472     );
473 }
474 ```
475
476 ## `comment_width`
477
478 Maximum length of comments. No effect unless`wrap_comments = true`.
479
480 - **Default value**: `80`
481 - **Possible values**: any positive integer
482 - **Stable**: No
483
484 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
485
486 #### `80` (default; comments shorter than `comment_width`):
487 ```rust
488 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
489 ```
490
491 #### `60` (comments longer than `comment_width`):
492 ```rust
493 // Lorem ipsum dolor sit amet,
494 // consectetur adipiscing elit.
495 ```
496
497 See also [`wrap_comments`](#wrap_comments).
498
499 ## `condense_wildcard_suffixes`
500
501 Replace strings of _ wildcards by a single .. in tuple patterns
502
503 - **Default value**: `false`
504 - **Possible values**: `true`, `false`
505 - **Stable**: No
506
507 #### `false` (default):
508
509 ```rust
510 fn main() {
511     let (lorem, ipsum, _, _) = (1, 2, 3, 4);
512     let (lorem, ipsum, ..) = (1, 2, 3, 4);
513 }
514 ```
515
516 #### `true`:
517
518 ```rust
519 fn main() {
520     let (lorem, ipsum, ..) = (1, 2, 3, 4);
521 }
522 ```
523
524 ## `control_brace_style`
525
526 Brace style for control flow constructs
527
528 - **Default value**: `"AlwaysSameLine"`
529 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
530 - **Stable**: No
531
532 #### `"AlwaysSameLine"` (default):
533
534 ```rust
535 fn main() {
536     if lorem {
537         println!("ipsum!");
538     } else {
539         println!("dolor!");
540     }
541 }
542 ```
543
544 #### `"AlwaysNextLine"`:
545
546 ```rust
547 fn main() {
548     if lorem
549     {
550         println!("ipsum!");
551     }
552     else
553     {
554         println!("dolor!");
555     }
556 }
557 ```
558
559 #### `"ClosingNextLine"`:
560
561 ```rust
562 fn main() {
563     if lorem {
564         println!("ipsum!");
565     }
566     else {
567         println!("dolor!");
568     }
569 }
570 ```
571
572 ## `disable_all_formatting`
573
574 Don't reformat anything
575
576 - **Default value**: `false`
577 - **Possible values**: `true`, `false`
578 - **Stable**: No
579
580 ## `error_on_line_overflow`
581
582 Error if unable to get all lines within `max_width`, except for comments and string literals.
583
584 - **Default value**: `true`
585 - **Possible values**: `true`, `false`
586 - **Stable**: No
587
588 See also [`max_width`](#max_width).
589
590 ## `error_on_unformatted`
591
592 Error if unable to get comments or string literals within `max_width`, or they are left with
593 trailing whitespaces.
594
595 - **Default value**: `false`
596 - **Possible values**: `true`, `false`
597 - **Stable**: No
598
599 ## `fn_args_density`
600
601 Argument density in functions
602
603 - **Default value**: `"Tall"`
604 - **Possible values**: `"Compressed"`, `"Tall"`, `"Vertical"`
605 - **Stable**: No
606
607 #### `"Tall"` (default):
608
609 ```rust
610 trait Lorem {
611     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
612
613     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
614         // body
615     }
616
617     fn lorem(
618         ipsum: Ipsum,
619         dolor: Dolor,
620         sit: Sit,
621         amet: Amet,
622         consectetur: Consectetur,
623         adipiscing: Adipiscing,
624         elit: Elit,
625     );
626
627     fn lorem(
628         ipsum: Ipsum,
629         dolor: Dolor,
630         sit: Sit,
631         amet: Amet,
632         consectetur: Consectetur,
633         adipiscing: Adipiscing,
634         elit: Elit,
635     ) {
636         // body
637     }
638 }
639 ```
640
641 #### `"Compressed"`:
642
643 ```rust
644 trait Lorem {
645     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
646
647     fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
648         // body
649     }
650
651     fn lorem(
652         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
653         adipiscing: Adipiscing, elit: Elit,
654     );
655
656     fn lorem(
657         ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
658         adipiscing: Adipiscing, elit: Elit,
659     ) {
660         // body
661     }
662 }
663 ```
664
665 #### `"Vertical"`:
666
667 ```rust
668 trait Lorem {
669     fn lorem(
670         ipsum: Ipsum,
671         dolor: Dolor,
672         sit: Sit,
673         amet: Amet,
674     );
675
676     fn lorem(
677         ipsum: Ipsum,
678         dolor: Dolor,
679         sit: Sit,
680         amet: Amet,
681     ) {
682         // body
683     }
684
685     fn lorem(
686         ipsum: Ipsum,
687         dolor: Dolor,
688         sit: Sit,
689         amet: Amet,
690         consectetur: Consectetur,
691         adipiscing: Adipiscing,
692         elit: Elit,
693     );
694
695     fn lorem(
696         ipsum: Ipsum,
697         dolor: Dolor,
698         sit: Sit,
699         amet: Amet,
700         consectetur: Consectetur,
701         adipiscing: Adipiscing,
702         elit: Elit,
703     ) {
704         // body
705     }
706 }
707 ```
708
709
710 ## `brace_style`
711
712 Brace style for items
713
714 - **Default value**: `"SameLineWhere"`
715 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
716 - **Stable**: No
717
718 ### Functions
719
720 #### `"SameLineWhere"` (default):
721
722 ```rust
723 fn lorem() {
724     // body
725 }
726
727 fn lorem(ipsum: usize) {
728     // body
729 }
730
731 fn lorem<T>(ipsum: T)
732 where
733     T: Add + Sub + Mul + Div,
734 {
735     // body
736 }
737 ```
738
739 #### `"AlwaysNextLine"`:
740
741 ```rust
742 fn lorem()
743 {
744     // body
745 }
746
747 fn lorem(ipsum: usize)
748 {
749     // body
750 }
751
752 fn lorem<T>(ipsum: T)
753 where
754     T: Add + Sub + Mul + Div,
755 {
756     // body
757 }
758 ```
759
760 #### `"PreferSameLine"`:
761
762 ```rust
763 fn lorem() {
764     // body
765 }
766
767 fn lorem(ipsum: usize) {
768     // body
769 }
770
771 fn lorem<T>(ipsum: T)
772 where
773     T: Add + Sub + Mul + Div, {
774     // body
775 }
776 ```
777
778 ### Structs and enums
779
780 #### `"SameLineWhere"` (default):
781
782 ```rust
783 struct Lorem {
784     ipsum: bool,
785 }
786
787 struct Dolor<T>
788 where
789     T: Eq,
790 {
791     sit: T,
792 }
793 ```
794
795 #### `"AlwaysNextLine"`:
796
797 ```rust
798 struct Lorem
799 {
800     ipsum: bool,
801 }
802
803 struct Dolor<T>
804 where
805     T: Eq,
806 {
807     sit: T,
808 }
809 ```
810
811 #### `"PreferSameLine"`:
812
813 ```rust
814 struct Lorem {
815     ipsum: bool,
816 }
817
818 struct Dolor<T>
819 where
820     T: Eq, {
821     sit: T,
822 }
823 ```
824
825
826 ## `empty_item_single_line`
827
828 Put empty-body functions and impls on a single line
829
830 - **Default value**: `true`
831 - **Possible values**: `true`, `false`
832 - **Stable**: No
833
834 #### `true` (default):
835
836 ```rust
837 fn lorem() {}
838
839 impl Lorem {}
840 ```
841
842 #### `false`:
843
844 ```rust
845 fn lorem() {
846 }
847
848 impl Lorem {
849 }
850 ```
851
852 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
853
854
855 ## `fn_single_line`
856
857 Put single-expression functions on a single line
858
859 - **Default value**: `false`
860 - **Possible values**: `true`, `false`
861 - **Stable**: No
862
863 #### `false` (default):
864
865 ```rust
866 fn lorem() -> usize {
867     42
868 }
869
870 fn lorem() -> usize {
871     let ipsum = 42;
872     ipsum
873 }
874 ```
875
876 #### `true`:
877
878 ```rust
879 fn lorem() -> usize { 42 }
880
881 fn lorem() -> usize {
882     let ipsum = 42;
883     ipsum
884 }
885 ```
886
887 See also [`control_brace_style`](#control_brace_style).
888
889
890 ## `where_single_line`
891
892 To force single line where layout
893
894 - **Default value**: `false`
895 - **Possible values**: `true`, `false`
896 - **Stable**: No
897
898 #### `false` (default):
899
900 ```rust
901 impl<T> Lorem for T
902 where
903     Option<T>: Ipsum,
904 {
905     // body
906 }
907 ```
908
909 #### `true`:
910
911 ```rust
912 impl<T> Lorem for T
913 where Option<T>: Ipsum
914 {
915     // body
916 }
917 ```
918
919 See also [`brace_style`](#brace_style), [`control_brace_style`](#control_brace_style).
920
921
922 ## `force_explicit_abi`
923
924 Always print the abi for extern items
925
926 - **Default value**: `true`
927 - **Possible values**: `true`, `false`
928 - **Stable**: Yes
929
930 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
931
932 #### `true` (default):
933
934 ```rust
935 extern "C" {
936     pub static lorem: c_int;
937 }
938 ```
939
940 #### `false`:
941
942 ```rust
943 extern {
944     pub static lorem: c_int;
945 }
946 ```
947
948 ## `format_strings`
949
950 Format string literals where necessary
951
952 - **Default value**: `false`
953 - **Possible values**: `true`, `false`
954 - **Stable**: No
955
956 #### `false` (default):
957
958 ```rust
959 fn main() {
960     let lorem =
961         "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet consectetur adipiscing";
962 }
963 ```
964
965 #### `true`:
966
967 ```rust
968 fn main() {
969     let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit amet \
970                  consectetur adipiscing";
971 }
972 ```
973
974 See also [`max_width`](#max_width).
975
976 ## `hard_tabs`
977
978 Use tab characters for indentation, spaces for alignment
979
980 - **Default value**: `false`
981 - **Possible values**: `true`, `false`
982 - **Stable**: Yes
983
984 #### `false` (default):
985
986 ```rust
987 fn lorem() -> usize {
988     42 // spaces before 42
989 }
990 ```
991
992 #### `true`:
993
994 ```rust
995 fn lorem() -> usize {
996         42 // tabs before 42
997 }
998 ```
999
1000 See also: [`tab_spaces`](#tab_spaces).
1001
1002
1003 ## `imports_indent`
1004
1005 Indent style of imports
1006
1007 - **Default Value**: `"Visual"`
1008 - **Possible values**: `"Block"`, `"Visual"`
1009 - **Stable**: No
1010
1011 #### `"Visual"` (default):
1012
1013 ```rust
1014 use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1015           zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz};
1016 ```
1017
1018 #### `"Block"`:
1019
1020 ```rust
1021 use foo::{
1022     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
1023     zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,
1024 };
1025 ```
1026
1027 See also: [`imports_layout`](#imports_layout).
1028
1029 ## `imports_layout`
1030
1031 Item layout inside a imports block
1032
1033 - **Default value**: "Mixed"
1034 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1035 - **Stable**: No
1036
1037 #### `"Mixed"` (default):
1038
1039 ```rust
1040 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1041
1042 use foo::{aaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb, cccccccccccccccccc, dddddddddddddddddd,
1043           eeeeeeeeeeeeeeeeee, ffffffffffffffffff};
1044 ```
1045
1046 #### `"Horizontal"`:
1047
1048 **Note**: This option forces all imports onto one line and may exceed `max_width`.
1049
1050 ```rust
1051 use foo::{xxx, yyy, zzz};
1052
1053 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1054 ```
1055
1056 #### `"HorizontalVertical"`:
1057
1058 ```rust
1059 use foo::{xxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz};
1060
1061 use foo::{aaaaaaaaaaaaaaaaaa,
1062           bbbbbbbbbbbbbbbbbb,
1063           cccccccccccccccccc,
1064           dddddddddddddddddd,
1065           eeeeeeeeeeeeeeeeee,
1066           ffffffffffffffffff};
1067 ```
1068
1069 #### `"Vertical"`:
1070
1071 ```rust
1072 use foo::{xxx,
1073           yyy,
1074           zzz};
1075
1076 use foo::{aaa,
1077           bbb,
1078           ccc,
1079           ddd,
1080           eee,
1081           fff};
1082 ```
1083
1084
1085 ## `match_block_trailing_comma`
1086
1087 Put a trailing comma after a block based match arm (non-block arms are not affected)
1088
1089 - **Default value**: `false`
1090 - **Possible values**: `true`, `false`
1091 - **Stable**: No
1092
1093 #### `false` (default):
1094
1095 ```rust
1096 fn main() {
1097     match lorem {
1098         Lorem::Ipsum => {
1099             println!("ipsum");
1100         }
1101         Lorem::Dolor => println!("dolor"),
1102     }
1103 }
1104 ```
1105
1106 #### `true`:
1107
1108 ```rust
1109 fn main() {
1110     match lorem {
1111         Lorem::Ipsum => {
1112             println!("ipsum");
1113         },
1114         Lorem::Dolor => println!("dolor"),
1115     }
1116 }
1117 ```
1118
1119 See also: [`trailing_comma`](#trailing_comma), [`match_arm_blocks`](#match_arm_blocks).
1120
1121 ## `max_width`
1122
1123 Maximum width of each line
1124
1125 - **Default value**: `100`
1126 - **Possible values**: any positive integer
1127 - **Stable**: Yes
1128
1129 See also [`error_on_line_overflow`](#error_on_line_overflow).
1130
1131 ## `merge_derives`
1132
1133 Merge multiple derives into a single one.
1134
1135 - **Default value**: `true`
1136 - **Possible values**: `true`, `false`
1137 - **Stable**: Yes
1138
1139 #### `true` (default):
1140
1141 ```rust
1142 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1143 pub enum Foo {}
1144 ```
1145
1146 #### `false`:
1147
1148 ```rust
1149 #[derive(Eq, PartialEq)]
1150 #[derive(Debug)]
1151 #[derive(Copy, Clone)]
1152 pub enum Foo {}
1153 ```
1154
1155 ## `force_multiline_blocks`
1156
1157 Force multiline closure and match arm bodies to be wrapped in a block
1158
1159 - **Default value**: `false`
1160 - **Possible values**: `false`, `true`
1161 - **Stable**: No
1162
1163 #### `false` (default):
1164
1165 ```rust
1166 fn main() {
1167     result.and_then(|maybe_value| match maybe_value {
1168         None => foo(),
1169         Some(value) => bar(),
1170     });
1171
1172     match lorem {
1173         None => if ipsum {
1174             println!("Hello World");
1175         },
1176         Some(dolor) => foo(),
1177     }
1178 }
1179 ```
1180
1181 #### `true`:
1182
1183 ```rust
1184 fn main() {
1185     result.and_then(|maybe_value| {
1186         match maybe_value {
1187             None => foo(),
1188             Some(value) => bar(),
1189         }
1190     });
1191
1192     match lorem {
1193         None => {
1194             if ipsum {
1195                 println!("Hello World");
1196             }
1197         }
1198         Some(dolor) => foo(),
1199     }
1200 }
1201 ```
1202
1203
1204 ## `newline_style`
1205
1206 Unix or Windows line endings
1207
1208 - **Default value**: `"Unix"`
1209 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1210 - **Stable**: Yes
1211
1212 ## `normalize_comments`
1213
1214 Convert /* */ comments to // comments where possible
1215
1216 - **Default value**: `false`
1217 - **Possible values**: `true`, `false`
1218 - **Stable**: Yes
1219
1220 #### `false` (default):
1221
1222 ```rust
1223 // Lorem ipsum:
1224 fn dolor() -> usize {}
1225
1226 /* sit amet: */
1227 fn adipiscing() -> usize {}
1228 ```
1229
1230 #### `true`:
1231
1232 ```rust
1233 // Lorem ipsum:
1234 fn dolor() -> usize {}
1235
1236 // sit amet:
1237 fn adipiscing() -> usize {}
1238 ```
1239
1240 ## `reorder_imported_names`
1241
1242 Reorder lists of names in import statements alphabetically
1243
1244 - **Default value**: `false`
1245 - **Possible values**: `true`, `false`
1246 - **Stable**: No
1247
1248 #### `false` (default):
1249
1250 ```rust
1251 use super::{lorem, ipsum, dolor, sit};
1252 ```
1253
1254 #### `true`:
1255
1256 ```rust
1257 use super::{dolor, ipsum, lorem, sit};
1258 ```
1259
1260 See also [`reorder_imports`](#reorder_imports).
1261
1262 ## `reorder_imports`
1263
1264 Reorder import statements alphabetically
1265
1266 - **Default value**: `false`
1267 - **Possible values**: `true`, `false`
1268 - **Stable**: No
1269
1270 #### `false` (default):
1271
1272 ```rust
1273 use lorem;
1274 use ipsum;
1275 use dolor;
1276 use sit;
1277 ```
1278
1279 #### `true`:
1280
1281 ```rust
1282 use dolor;
1283 use ipsum;
1284 use lorem;
1285 use sit;
1286 ```
1287
1288 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1289
1290 ## `reorder_imports_in_group`
1291
1292 Reorder import statements in group
1293
1294 - **Default value**: `false`
1295 - **Possible values**: `true`, `false`
1296 - **Stable**: No
1297
1298 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1299
1300 #### `true` (default):
1301
1302 ```rust
1303 use std::io;
1304 use std::mem;
1305
1306 use dolor;
1307 use ipsum;
1308 use lorem;
1309 use sit;
1310 ```
1311
1312 #### `false`:
1313
1314
1315 ```rust
1316 use dolor;
1317 use ipsum;
1318 use lorem;
1319 use sit;
1320 use std::io;
1321 use std::mem;
1322 ```
1323
1324 See also [`reorder_imports`](#reorder_imports).
1325
1326 ## `reorder_extern_crates`
1327
1328 Reorder `extern crate` statements alphabetically
1329
1330 - **Default value**: `true`
1331 - **Possible values**: `true`, `false`
1332 - **Stable**: No
1333
1334 #### `true` (default):
1335
1336 ```rust
1337 extern crate dolor;
1338 extern crate ipsum;
1339 extern crate lorem;
1340 extern crate sit;
1341 ```
1342
1343 #### `false`:
1344
1345 ```rust
1346 extern crate lorem;
1347 extern crate ipsum;
1348
1349 extern crate dolor;
1350 extern crate sit;
1351 ```
1352
1353 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1354
1355 ## `reorder_extern_crates_in_group`
1356
1357 Reorder `extern crate` statements in group
1358
1359 - **Default value**: `true`
1360 - **Possible values**: `true`, `false`
1361 - **Stable**: No
1362
1363 #### `false` (default):
1364
1365 This value has no influence beyond the effect of the [`reorder_extern_crates`](#reorder_extern_crates) option. Set [`reorder_extern_crates`](#reorder_extern_crates) to `false` if you do not want `extern crate` groups to be collapsed and ordered.
1366
1367 #### `true`:
1368
1369 **Note:** This only takes effect when [`reorder_extern_crates`](#reorder_extern_crates) is set to `true`.
1370
1371 ```rust
1372 extern crate a;
1373 extern crate b;
1374
1375 extern crate dolor;
1376 extern crate ipsum;
1377 extern crate lorem;
1378 extern crate sit;
1379 ```
1380
1381 ## `reorder_modules`
1382
1383 Reorder `mod` declarations alphabetically in group.
1384
1385 - **Default value**: `true`
1386 - **Possible values**: `true`, `false`
1387 - **Stable**: No
1388
1389 #### `true` (default)
1390
1391 ```rust
1392 mod a;
1393 mod b;
1394
1395 mod dolor;
1396 mod ipsum;
1397 mod lorem;
1398 mod sit;
1399 ```
1400
1401 #### `false`
1402
1403 ```rust
1404 mod b;
1405 mod a;
1406
1407 mod lorem;
1408 mod ipsum;
1409 mod dolor;
1410 mod sit;
1411 ```
1412
1413 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantic
1414 of the original source code.
1415
1416 ## `report_todo`
1417
1418 Report `TODO` items in comments.
1419
1420 - **Default value**: `"Never"`
1421 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1422 - **Stable**: No
1423
1424 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1425 it contains a `#X` (with `X` being a number) in parentheses following the
1426 `TODO`, `"Unnumbered"` will ignore it.
1427
1428 See also [`report_fixme`](#report_fixme).
1429
1430 ## `report_fixme`
1431
1432 Report `FIXME` items in comments.
1433
1434 - **Default value**: `"Never"`
1435 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1436 - **Stable**: No
1437
1438 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1439 it contains a `#X` (with `X` being a number) in parentheses following the
1440 `FIXME`, `"Unnumbered"` will ignore it.
1441
1442 See also [`report_todo`](#report_todo).
1443
1444
1445 ## `skip_children`
1446
1447 Don't reformat out of line modules
1448
1449 - **Default value**: `false`
1450 - **Possible values**: `true`, `false`
1451 - **Stable**: No
1452
1453 ## `space_after_colon`
1454
1455 Leave a space after the colon.
1456
1457 - **Default value**: `true`
1458 - **Possible values**: `true`, `false`
1459 - **Stable**: No
1460
1461 #### `true` (default):
1462
1463 ```rust
1464 fn lorem<T: Eq>(t: T) {
1465     let lorem: Dolor = Lorem {
1466         ipsum: dolor,
1467         sit: amet,
1468     };
1469 }
1470 ```
1471
1472 #### `false`:
1473
1474 ```rust
1475 fn lorem<T:Eq>(t:T) {
1476     let lorem:Dolor = Lorem {
1477         ipsum:dolor,
1478         sit:amet,
1479     };
1480 }
1481 ```
1482
1483 See also: [`space_before_colon`](#space_before_colon).
1484
1485 ## `space_before_colon`
1486
1487 Leave a space before the colon.
1488
1489 - **Default value**: `false`
1490 - **Possible values**: `true`, `false`
1491 - **Stable**: No
1492
1493 #### `false` (default):
1494
1495 ```rust
1496 fn lorem<T: Eq>(t: T) {
1497     let lorem: Dolor = Lorem {
1498         ipsum: dolor,
1499         sit: amet,
1500     };
1501 }
1502 ```
1503
1504 #### `true`:
1505
1506 ```rust
1507 fn lorem<T : Eq>(t : T) {
1508     let lorem : Dolor = Lorem {
1509         ipsum : dolor,
1510         sit : amet,
1511     };
1512 }
1513 ```
1514
1515 See also: [`space_after_colon`](#space_after_colon).
1516
1517 ## `struct_field_align_threshold`
1518
1519 The maximum diff of width between struct fields to be aligned with each other.
1520
1521 - **Default value** : 0
1522 - **Possible values**: any positive integer
1523 - **Stable**: No
1524
1525 #### `0` (default):
1526
1527 ```rust
1528 struct Foo {
1529     x: u32,
1530     yy: u32,
1531     zzz: u32,
1532 }
1533 ```
1534
1535 #### `20`:
1536
1537 ```rust
1538 struct Foo {
1539     x:   u32,
1540     yy:  u32,
1541     zzz: u32,
1542 }
1543 ```
1544
1545 ## `spaces_around_ranges`
1546
1547 Put spaces around the .., ..=, and ... range operators
1548
1549 - **Default value**: `false`
1550 - **Possible values**: `true`, `false`
1551 - **Stable**: No
1552
1553 #### `false` (default):
1554
1555 ```rust
1556 fn main() {
1557     let lorem = 0..10;
1558     let ipsum = 0..=10;
1559
1560     match lorem {
1561         1..5 => foo(),
1562         _ => bar,
1563     }
1564
1565     match lorem {
1566         1..=5 => foo(),
1567         _ => bar,
1568     }
1569
1570     match lorem {
1571         1...5 => foo(),
1572         _ => bar,
1573     }
1574 }
1575 ```
1576
1577 #### `true`:
1578
1579 ```rust
1580 fn main() {
1581     let lorem = 0 .. 10;
1582     let ipsum = 0 ..= 10;
1583
1584     match lorem {
1585         1 .. 5 => foo(),
1586         _ => bar,
1587     }
1588
1589     match lorem {
1590         1 ..= 5 => foo(),
1591         _ => bar,
1592     }
1593
1594     match lorem {
1595         1 ... 5 => foo(),
1596         _ => bar,
1597     }
1598 }
1599 ```
1600
1601 ## `spaces_within_parens_and_brackets`
1602
1603 Put spaces within non-empty generic arguments, parentheses, and square brackets
1604
1605 - **Default value**: `false`
1606 - **Possible values**: `true`, `false`
1607 - **Stable**: No
1608
1609 #### `false` (default):
1610
1611 ```rust
1612 // generic arguments
1613 fn lorem<T: Eq>(t: T) {
1614     // body
1615 }
1616
1617 // non-empty parentheses
1618 fn lorem<T: Eq>(t: T) {
1619     let lorem = (ipsum, dolor);
1620 }
1621
1622 // non-empty square brackets
1623 fn lorem<T: Eq>(t: T) {
1624     let lorem: [usize; 2] = [ipsum, dolor];
1625 }
1626 ```
1627
1628 #### `true`:
1629
1630 ```rust
1631 // generic arguments
1632 fn lorem< T: Eq >( t: T ) {
1633     // body
1634 }
1635
1636 // non-empty parentheses
1637 fn lorem< T: Eq >( t: T ) {
1638     let lorem = ( ipsum, dolor );
1639 }
1640
1641 // non-empty square brackets
1642 fn lorem< T: Eq >( t: T ) {
1643     let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1644 }
1645 ```
1646
1647 ## `struct_lit_single_line`
1648
1649 Put small struct literals on a single line
1650
1651 - **Default value**: `true`
1652 - **Possible values**: `true`, `false`
1653 - **Stable**: No
1654
1655 #### `true` (default):
1656
1657 ```rust
1658 fn main() {
1659     let lorem = Lorem { foo: bar, baz: ofo };
1660 }
1661 ```
1662
1663 #### `false`:
1664
1665 ```rust
1666 fn main() {
1667     let lorem = Lorem {
1668         foo: bar,
1669         baz: ofo,
1670     };
1671 }
1672 ```
1673
1674 See also: [`indent_style`](#indent_style).
1675
1676
1677 ## `tab_spaces`
1678
1679 Number of spaces per tab
1680
1681 - **Default value**: `4`
1682 - **Possible values**: any positive integer
1683 - **Stable**: Yes
1684
1685 #### `4` (default):
1686
1687 ```rust
1688 fn lorem() {
1689     let ipsum = dolor();
1690     let sit = vec![
1691         "amet consectetur adipiscing elit amet",
1692         "consectetur adipiscing elit amet consectetur.",
1693     ];
1694 }
1695 ```
1696
1697 #### `2`:
1698
1699 ```rust
1700 fn lorem() {
1701   let ipsum = dolor();
1702   let sit = vec![
1703     "amet consectetur adipiscing elit amet",
1704     "consectetur adipiscing elit amet consectetur.",
1705   ];
1706 }
1707 ```
1708
1709 See also: [`hard_tabs`](#hard_tabs).
1710
1711
1712 ## `trailing_comma`
1713
1714 How to handle trailing commas for lists
1715
1716 - **Default value**: `"Vertical"`
1717 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
1718 - **Stable**: No
1719
1720 #### `"Vertical"` (default):
1721
1722 ```rust
1723 fn main() {
1724     let Lorem { ipsum, dolor, sit } = amet;
1725     let Lorem {
1726         ipsum,
1727         dolor,
1728         sit,
1729         amet,
1730         consectetur,
1731         adipiscing,
1732     } = elit;
1733 }
1734 ```
1735
1736 #### `"Always"`:
1737
1738 ```rust
1739 fn main() {
1740     let Lorem { ipsum, dolor, sit, } = amet;
1741     let Lorem {
1742         ipsum,
1743         dolor,
1744         sit,
1745         amet,
1746         consectetur,
1747         adipiscing,
1748     } = elit;
1749 }
1750 ```
1751
1752 #### `"Never"`:
1753
1754 ```rust
1755 fn main() {
1756     let Lorem { ipsum, dolor, sit } = amet;
1757     let Lorem {
1758         ipsum,
1759         dolor,
1760         sit,
1761         amet,
1762         consectetur,
1763         adipiscing
1764     } = elit;
1765 }
1766 ```
1767
1768 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
1769
1770 ## `trailing_semicolon`
1771
1772 Add trailing semicolon after break, continue and return
1773
1774 - **Default value**: `true`
1775 - **Possible values**: `true`, `false`
1776 - **Stable**: No
1777
1778 #### `true` (default):
1779 ```rust
1780 fn foo() -> usize {
1781     return 0;
1782 }
1783 ```
1784
1785 #### `false`:
1786 ```rust
1787 fn foo() -> usize {
1788     return 0
1789 }
1790 ```
1791
1792 ## `type_punctuation_density`
1793
1794 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
1795
1796 - **Default value**: `"Wide"`
1797 - **Possible values**: `"Compressed"`, `"Wide"`
1798 - **Stable**: No
1799
1800 #### `"Wide"` (default):
1801
1802 ```rust
1803 fn lorem<Ipsum: Dolor + Sit = Amet>() {
1804     // body
1805 }
1806 ```
1807
1808 #### `"Compressed"`:
1809
1810 ```rust
1811 fn lorem<Ipsum: Dolor+Sit=Amet>() {
1812     // body
1813 }
1814 ```
1815
1816 ## `use_field_init_shorthand`
1817
1818 Use field initialize shorthand if possible.
1819
1820 - **Default value**: `false`
1821 - **Possible values**: `true`, `false`
1822 - **Stable**: No
1823
1824 #### `false` (default):
1825
1826 ```rust
1827 struct Foo {
1828     x: u32,
1829     y: u32,
1830     z: u32,
1831 }
1832
1833 fn main() {
1834     let x = 1;
1835     let y = 2;
1836     let z = 3;
1837     let a = Foo { x: x, y: y, z: z };
1838 }
1839 ```
1840
1841 #### `true`:
1842
1843 ```rust
1844 struct Foo {
1845     x: u32,
1846     y: u32,
1847     z: u32,
1848 }
1849
1850 fn main() {
1851     let x = 1;
1852     let y = 2;
1853     let z = 3;
1854     let a = Foo { x, y, z };
1855 }
1856 ```
1857
1858 ## `use_try_shorthand`
1859
1860 Replace uses of the try! macro by the ? shorthand
1861
1862 - **Default value**: `false`
1863 - **Possible values**: `true`, `false`
1864 - **Stable**: No
1865
1866 #### `false` (default):
1867
1868 ```rust
1869 fn main() {
1870     let lorem = try!(ipsum.map(|dolor| dolor.sit()));
1871 }
1872 ```
1873
1874 #### `true`:
1875
1876 ```rust
1877 fn main() {
1878     let lorem = ipsum.map(|dolor| dolor.sit())?;
1879 }
1880 ```
1881
1882
1883 ## `wrap_comments`
1884
1885 Break comments to fit on the line
1886
1887 - **Default value**: `false`
1888 - **Possible values**: `true`, `false`
1889 - **Stable**: Yes
1890
1891 #### `false` (default):
1892
1893 ```rust
1894 // 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.
1895 ```
1896
1897 #### `true`:
1898
1899 ```rust
1900 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
1901 // sed do eiusmod tempor incididunt ut labore et dolore
1902 // magna aliqua. Ut enim ad minim veniam, quis nostrud
1903 // exercitation ullamco laboris nisi ut aliquip ex ea
1904 // commodo consequat.
1905 ```
1906
1907 ## `match_arm_blocks`
1908
1909 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
1910
1911 - **Default value**: `true`
1912 - **Possible values**: `true`, `false`
1913 - **Stable**: No
1914
1915 #### `true` (default):
1916
1917 ```rust
1918 fn main() {
1919     match lorem {
1920         true => {
1921             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
1922         }
1923         false => println!("{}", sit),
1924     }
1925 }
1926 ```
1927
1928 #### `false`:
1929
1930 ```rust
1931 fn main() {
1932     match lorem {
1933         true =>
1934             foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
1935         false => println!("{}", sit),
1936     }
1937 }
1938 ```
1939
1940 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
1941
1942 ## `write_mode`
1943
1944 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
1945
1946 - **Default value**: `"Overwrite"`
1947 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`
1948 - **Stable**: No
1949
1950 ## `blank_lines_upper_bound`
1951
1952 Maximum number of blank lines which can be put between items. If more than this number of consecutive empty
1953 lines are found, they are trimmed down to match this integer.
1954
1955 - **Default value**: `1`
1956 - **Possible values**: *unsigned integer*
1957 - **Stable**: No
1958
1959 ### Example
1960 Original Code:
1961
1962 ```rust
1963 #![rustfmt_skip]
1964
1965 fn foo() {
1966     println!("a");
1967 }
1968
1969
1970
1971 fn bar() {
1972     println!("b");
1973
1974
1975     println!("c");
1976 }
1977 ```
1978
1979 #### `1` (default):
1980 ```rust
1981 fn foo() {
1982     println!("a");
1983 }
1984
1985 fn bar() {
1986     println!("b");
1987
1988     println!("c");
1989 }
1990 ```
1991
1992 #### `2` (default):
1993 ```rust
1994 fn foo() {
1995     println!("a");
1996 }
1997
1998
1999 fn bar() {
2000     println!("b");
2001
2002
2003     println!("c");
2004 }
2005 ```
2006
2007 See also: [`blank_lines_lower_bound`](#blank_lines_lower_bound)
2008
2009 ## `blank_lines_lower_bound`
2010
2011 Minimum number of blank lines which must be put between items. If two items have fewer blank lines between
2012 them, additional blank lines are inserted.
2013
2014 - **Default value**: `0`
2015 - **Possible values**: *unsigned integer*
2016 - **Stable**: No
2017
2018 ### Example
2019 Original Code (rustfmt will not change it with the default value of `0`):
2020
2021 ```rust
2022 #![rustfmt_skip]
2023
2024 fn foo() {
2025     println!("a");
2026 }
2027 fn bar() {
2028     println!("b");
2029     println!("c");
2030 }
2031 ```
2032
2033 #### `1`
2034 ```rust
2035 fn foo() {
2036
2037     println!("a");
2038 }
2039
2040 fn bar() {
2041
2042     println!("b");
2043
2044     println!("c");
2045 }
2046 ```
2047
2048 ## `remove_blank_lines_at_start_or_end_of_block`
2049
2050 Remove blank lines at the start or the end of a block.
2051
2052 - **Default value**: `true`
2053 - **Possible values**: `true`, `false`
2054 - **Stable**: No
2055
2056 #### `true`
2057
2058 ```rust
2059 fn foo() {
2060     let msg = {
2061         let mut str = String::new();
2062         str.push_str("hello, ");
2063         str.push_str("world!");
2064         str
2065     };
2066     println!("{}", msg);
2067 }
2068 ```
2069
2070 #### `false`
2071
2072 ```rust
2073 fn foo() {
2074
2075     let msg = {
2076
2077         let mut str = String::new();
2078         str.push_str("hello, ");
2079         str.push_str("world!");
2080         str
2081
2082     };
2083     println!("{}", msg);
2084
2085 }
2086 ```
2087
2088 ## `required_version`
2089
2090 Require a specific version of rustfmt. If you want to make sure that the 
2091 specific version of rustfmt is used in your CI, use this option.
2092
2093 - **Default value**: `CARGO_PKG_VERSION`
2094 - **Possible values**: any published version (e.g. `"0.3.8"`)
2095 - **Stable**: No
2096
2097 ## `hide_parse_errors`
2098
2099 Do not show parse errors if the parser failed to parse files.
2100
2101 - **Default value**: `false`
2102 - **Possible values**: `true`, `false`
2103 - **Stable**: No
2104
2105 ## `color`
2106
2107 Whether to use colored output or not.
2108
2109 - **Default value**: `"Auto"`
2110 - **Possible values**: "Auto", "Always", "Never"
2111 - **Stable**: No
2112
2113 ## `unstable_features`
2114
2115 Enable unstable features on stable channel.
2116
2117 - **Default value**: `false`
2118 - **Possible values**: `true`, `false`
2119 - **Stable**: Yes
2120
2121 ## `license_template_path`
2122
2123 Check whether beginnings of files match a license template.
2124
2125 - **Default value**: `""``
2126 - **Possible values**: path to a license template file
2127 - **Stable**: No
2128
2129 A license template is a plain text file which is matched literally against the
2130 beginning of each source file, except for `{}`-delimited blocks, which are
2131 matched as regular expressions. The following license template therefore
2132 matches strings like `// Copyright 2017 The Rust Project Developers.`, `//
2133 Copyright 2018 The Rust Project Developers.`, etc.:
2134
2135 ```
2136 // Copyright {\d+} The Rust Project Developers.
2137 ```
2138
2139 `\{`, `\}` and `\\` match literal braces / backslashes.
2140
2141 ## `ignore`
2142
2143 Skip formatting the specified files and directories.
2144
2145 - **Default value**: format every files
2146 - **Possible values**: See an example below
2147 - **Stable**: No
2148
2149 ### Example
2150
2151 If you want to ignore specific files, put the following to your config file:
2152
2153 ```toml
2154 ignore = [
2155     "src/types.rs",
2156     "src/foo/bar.rs",
2157 ]
2158 ```
2159
2160 If you want to ignore every file under `examples/`, put the following to your config file:
2161
2162 ```toml
2163 ignore [
2164     "examples",
2165 ]
2166 ```