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.
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
10 reorder_imported_names = true
13 # Configuration Options
15 Below you find a detailed visual guide on all the supported configuration options of rustfmt:
17 ## `array_horizontal_layout_threshold`
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.
22 - **Default value**: `0`
23 - **Possible values**: any positive integer
25 **Note:** A value of `0` results in [`array_indent`](#array_indent) being applied regardless of a line's width.
30 // Each element will be placed on its own line.
46 // Each element will be placed on the same line as much as possible.
57 - **Default value**: `"Block"`
58 - **Possible values**: `"Block"`, `"Visual"`
60 #### `"Block"` (default):
77 let lorem = vec!["ipsum",
88 Maximum width of an array literal before falling back to vertical formatting
90 - **Default value**: `60`
91 - **Possible values**: any positive integer
93 **Note:** A value of `0` results in [`array_indent`](#array_indent) being applied regardless of a line's width.
95 #### Lines shorter than `array_width`:
97 let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit"];
100 #### Lines longer than `array_width`:
101 See [`array_indent`](#array_indent).
103 ## `attributes_on_same_line_as_field`
105 Try to put attributes on the same line as fields
107 - **Default value**: `true`
108 - **Possible values**: `true`, `false`
110 #### `true` (default):
114 #[serde(rename = "Ipsum")] ipsum: usize,
115 #[serde(rename = "Dolor")] dolor: usize,
116 #[serde(rename = "Amet")] amet: usize,
124 #[serde(rename = "Ipsum")]
126 #[serde(rename = "Dolor")]
128 #[serde(rename = "Amet")]
133 ## `attributes_on_same_line_as_variant`
135 Try to put attributes on the same line as variants
137 - **Default value**: `true`
138 - **Possible values**: `true`, `false`
140 #### `true` (default):
144 #[serde(skip_serializing)] Ipsum,
145 #[serde(skip_serializing)] Dolor,
146 #[serde(skip_serializing)] Amet,
154 #[serde(skip_serializing)]
156 #[serde(skip_serializing)]
158 #[serde(skip_serializing)]
165 Where to put a binary operator when a binary expression goes multiline.
167 - **Default value**: `"Front"`
168 - **Possible values**: `"Front"`, `"Back"`
170 #### `"Front"` (default):
181 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
182 ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
196 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
197 bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
204 - **Default value**: `"Block"`
205 - **Possible values**: `"Block"`, `"Visual"`
207 #### `"Block"` (default):
222 let lorem = ipsum.dolor()
230 See also [`chain_width`](#chain_width).
234 Maximum length of a chain to fit on a single line
236 - **Default value**: `60`
237 - **Possible values**: any positive integer
239 #### Lines shorter than `chain_width`:
241 let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
244 #### Lines longer than `chain_width`:
245 See [`chain_indent`](#chain_indent).
247 ## `chain_split_single_child`
249 Split a chain with a single child if its length exceeds [`chain_width`](#chain_width).
251 - **Default value**: `false`
252 - **Possible values**: `false`, `true`
254 #### `false` (default):
257 let files = fs::read_dir("tests/coverage/source").expect("Couldn't read source dir");
263 let files = fs::read_dir("tests/coverage/source")
264 .expect("Couldn't read source dir");
267 See also [`chain_width`](#chain_width).
269 ## `combine_control_expr`
271 Combine control expressions with function calls.
273 - **Default value**: `true`
274 - **Possible values**: `true`, `false`
276 #### `true` (default):
288 foo!(if let Some(..) = x {
301 foo!(while let Some(..) = x {
335 if let Some(..) = x {
352 while let Some(..) = x {
378 Maximum length of comments. No effect unless`wrap_comments = true`.
380 - **Default value**: `80`
381 - **Possible values**: any positive integer
383 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
385 #### Comments shorter than `comment_width`:
387 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
390 #### Comments longer than `comment_width`:
392 // Lorem ipsum dolor sit amet,
393 // consectetur adipiscing elit.
396 See also [`wrap_comments`](#wrap_comments).
398 ## `condense_wildcard_suffixes`
400 Replace strings of _ wildcards by a single .. in tuple patterns
402 - **Default value**: `false`
403 - **Possible values**: `true`, `false`
405 #### `false` (default):
408 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
414 let (lorem, ipsum, ..) = (1, 2, 3, 4);
419 Indent style for control flow statements
421 - **Default value**: `"Rfc"`
422 - **Possible values**: `"Rfc"`, `"Legacy"`
424 #### `"Rfc"` (default):
445 See also: [`control_brace_style`](#control_brace_style).
447 ## `control_brace_style`
449 Brace style for control flow constructs
451 - **Default value**: `"AlwaysSameLine"`
452 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
454 #### `"AlwaysSameLine"` (default):
464 #### `"AlwaysNextLine"`:
477 #### `"ClosingNextLine"`:
488 ## `disable_all_formatting`
490 Don't reformat anything
492 - **Default value**: `false`
493 - **Possible values**: `true`, `false`
495 ## `error_on_line_overflow`
497 Error if unable to get all lines within `max_width`
499 - **Default value**: `true`
500 - **Possible values**: `true`, `false`
502 See also [`max_width`](#max_width).
504 ## `error_on_line_overflow_comments`
506 Error if unable to get all comment lines within `comment_width`.
508 - **Default value**: `true`
509 - **Possible values**: `true`, `false`
511 See also [`comment_width`](#comment_width).
515 Argument density in functions
517 - **Default value**: `"Tall"`
518 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
520 #### `"Tall"` (default):
524 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
526 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
535 consectetur: Consectetur,
536 adipiscing: Adipiscing,
545 consectetur: Consectetur,
546 adipiscing: Adipiscing,
558 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
560 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
565 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
566 adipiscing: Adipiscing, elit: Elit,
570 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
571 adipiscing: Adipiscing, elit: Elit,
578 #### `"CompressedIfEmpty"`:
582 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
584 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
589 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
590 adipiscing: Adipiscing, elit: Elit,
598 consectetur: Consectetur,
599 adipiscing: Adipiscing,
611 fn lorem(ipsum: Ipsum,
616 fn lorem(ipsum: Ipsum,
623 fn lorem(ipsum: Ipsum,
627 consectetur: Consectetur,
628 adipiscing: Adipiscing,
631 fn lorem(ipsum: Ipsum,
635 consectetur: Consectetur,
636 adipiscing: Adipiscing,
645 Layout of function arguments and tuple structs
647 - **Default value**: `"Block"`
648 - **Possible values**: `"Block"`, `"Visual"`
650 #### `"Block"` (default):
655 fn lorem(ipsum: usize) {}
675 fn lorem(ipsum: usize) {}
677 fn lorem(ipsum: usize,
688 ## `fn_args_paren_newline`
690 If function argument parenthesis goes on a newline
692 - **Default value**: `false`
693 - **Possible values**: `true`, `false`
695 #### `false` (default):
703 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
717 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
724 Brace style for functions
726 - **Default value**: `"SameLineWhere"`
727 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
729 #### `"SameLineWhere"` (default):
736 fn lorem(ipsum: usize) {
740 fn lorem<T>(ipsum: T)
742 T: Add + Sub + Mul + Div,
748 #### `"AlwaysNextLine"`:
756 fn lorem(ipsum: usize)
761 fn lorem<T>(ipsum: T)
763 T: Add + Sub + Mul + Div,
769 #### `"PreferSameLine"`:
776 fn lorem(ipsum: usize) {
780 fn lorem<T>(ipsum: T)
782 T: Add + Sub + Mul + Div, {
789 Indentation for function calls, etc.
791 - **Default value**: `"Block"`
792 - **Possible values**: `"Block"`, `"Visual"`
794 #### `"Block"` (default):
824 Maximum width of the args of a function call before falling back to vertical formatting
826 - **Default value**: `60`
827 - **Possible values**: any positive integer
829 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
831 #### Function call shorter than `fn_call_width`:
833 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
836 #### Function call longer than `fn_call_width`:
838 See [`fn_call_indent`](#fn_call_indent).
840 ## `fn_empty_single_line`
842 Put empty-body functions on a single line
844 - **Default value**: `true`
845 - **Possible values**: `true`, `false`
847 #### `true` (default):
860 See also [`control_brace_style`](#control_brace_style).
862 ## `fn_return_indent`
864 Location of return type in function declaration
866 - **Default value**: `"WithArgs"`
867 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
869 #### `"WithArgs"` (default):
872 fn lorem(ipsum: Ipsum,
876 consectetur: Consectetur,
877 adipiscing: Adipiscing)
886 #### `"WithWhereClause"`:
889 fn lorem(ipsum: Ipsum,
893 consectetur: Consectetur,
894 adipiscing: Adipiscing)
903 **Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`.
907 Put single-expression functions on a single line
909 - **Default value**: `false`
910 - **Possible values**: `true`, `false`
912 #### `false` (default):
915 fn lorem() -> usize {
919 fn lorem() -> usize {
928 fn lorem() -> usize { 42 }
930 fn lorem() -> usize {
936 See also [`control_brace_style`](#control_brace_style).
938 ## `force_explicit_abi`
940 Always print the abi for extern items
942 - **Default value**: `true`
943 - **Possible values**: `true`, `false`
945 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
947 #### `true` (default):
951 pub static lorem: c_int;
959 pub static lorem: c_int;
963 ## `force_format_strings`
965 Always format string literals
967 - **Default value**: `false`
968 - **Possible values**: `true`, `false`
970 See [`format_strings`](#format_strings).
972 See also [`max_width`](#max_width).
976 Format string literals where necessary
978 - **Default value**: `false`
979 - **Possible values**: `true`, `false`
981 #### `false` (default):
984 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
991 "ipsum dolor sit amet consectetur \
992 adipiscing elit lorem ipsum dolor sit";
995 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
999 Indentation of generics
1001 - **Default value**: `"Block"`
1002 - **Possible values**: `"Block"`, `"Visual"`
1004 #### `"Block"` (default):
1012 Adipiscing: Eq = usize,
1013 Consectetur: Eq = usize,
1020 adipiscing: Adipiscing,
1021 consectetur: Consectetur,
1031 fn lorem<Ipsum: Eq = usize,
1035 Adipiscing: Eq = usize,
1036 Consectetur: Eq = usize,
1042 adipiscing: Adipiscing,
1043 consectetur: Consectetur,
1052 Use tab characters for indentation, spaces for alignment
1054 - **Default value**: `false`
1055 - **Possible values**: `true`, `false`
1057 #### `false` (default):
1060 fn lorem() -> usize {
1061 42 // spaces before 42
1068 fn lorem() -> usize {
1069 42 // tabs before 42
1073 See also: [`tab_spaces`](#tab_spaces).
1075 ## `impl_empty_single_line`
1077 Put empty-body implementations on a single line
1079 - **Default value**: `true`
1080 - **Possible values**: `true`, `false`
1082 #### `true` (default):
1095 See also [`item_brace_style`](#item_brace_style).
1097 ## `indent_match_arms`
1099 Indent match arms instead of keeping them at the same indentation level as the match keyword
1101 - **Default value**: `true`
1102 - **Possible values**: `true`, `false`
1104 #### `true` (default):
1126 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1130 Indent style of imports
1132 - **Default Value**: `"Visual"`
1133 - **Possible values**: `"Block"`, `"Visual"`
1135 #### `"Visual"` (default):
1153 See also: [`imports_layout`](#imports_layout).
1157 Item layout inside a imports block
1159 - **Default value**: "Mixed"
1160 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1162 #### `"Mixed"` (default):
1165 use foo::{xxx, yyy, zzz};
1167 use foo::{aaa, bbb, ccc,
1171 #### `"Horizontal"`:
1173 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1176 use foo::{xxx, yyy, zzz};
1178 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1181 #### `"HorizontalVertical"`:
1184 use foo::{xxx, yyy, zzz};
1209 ## `item_brace_style`
1211 Brace style for structs and enums
1213 - **Default value**: `"SameLineWhere"`
1214 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1216 #### `"SameLineWhere"` (default):
1230 #### `"AlwaysNextLine"`:
1245 #### `"PreferSameLine"`:
1258 ## `match_arm_forces_newline`
1260 Consistently put match arms (block based or not) in a newline.
1262 - **Default value**: `false`
1263 - **Possible values**: `true`, `false`
1265 #### `false` (default):
1269 // a non-empty block
1276 X2 => println!("ok"),
1284 // a non-empty block
1298 See also: [`wrap_match_arms`](#wrap_match_arms).
1300 ## `match_block_trailing_comma`
1302 Put a trailing comma after a block based match arm (non-block arms are not affected)
1304 - **Default value**: `false`
1305 - **Possible values**: `true`, `false`
1307 #### `false` (default):
1314 Lorem::Dolor => println!("dolor"),
1325 Lorem::Dolor => println!("dolor"),
1329 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1331 ## `match_pattern_separator_break_point`
1333 Put a match sub-patterns' separator (`|`) in front or back.
1335 - **Default value**: `"Back"`
1336 - **Possible values**: `"Back"`, `"Front"`
1338 #### `"Back"` (default):
1360 | Variant::Tag6 => {}
1366 Maximum width of each line
1368 - **Default value**: `100`
1369 - **Possible values**: any positive integer
1371 See also [`error_on_line_overflow`](#error_on_line_overflow).
1375 Merge multiple derives into a single one.
1377 - **Default value**: `true`
1378 - **Possible values**: `true`, `false`
1380 #### `true` (default):
1383 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1390 #[derive(Eq, PartialEq)]
1392 #[derive(Copy, Clone)]
1396 ## `multiline_closure_forces_block`
1398 Force multiline closure bodies to be wrapped in a block
1400 - **Default value**: `false`
1401 - **Possible values**: `false`, `true`
1403 #### `false` (default):
1406 result.and_then(|maybe_value| match maybe_value {
1416 result.and_then(|maybe_value| {
1424 ## `multiline_match_arm_forces_block`
1426 Force multiline match arm bodies to be wrapped in a block
1428 - **Default value**: `false`
1429 - **Possible values**: `false`, `true`
1431 #### `false` (default):
1436 println!("Hello World");
1448 println!("Hello World");
1457 Unix or Windows line endings
1459 - **Default value**: `"Unix"`
1460 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1462 ## `normalize_comments`
1464 Convert /* */ comments to // comments where possible
1466 - **Default value**: `false`
1467 - **Possible values**: `true`, `false`
1469 #### `false` (default):
1473 fn dolor() -> usize {}
1476 fn adipiscing() -> usize {}
1483 fn dolor() -> usize {}
1486 fn adipiscing() -> usize {}
1489 ## `reorder_imported_names`
1491 Reorder lists of names in import statements alphabetically
1493 - **Default value**: `false`
1494 - **Possible values**: `true`, `false`
1496 #### `false` (default):
1499 use super::{lorem, ipsum, dolor, sit};
1505 use super::{dolor, ipsum, lorem, sit};
1508 See also [`reorder_imports`](#reorder_imports).
1510 ## `reorder_imports`
1512 Reorder import statements alphabetically
1514 - **Default value**: `false`
1515 - **Possible values**: `true`, `false`
1517 #### `false` (default):
1535 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1537 ## `reorder_imports_in_group`
1539 Reorder import statements in group
1541 - **Default value**: `false`
1542 - **Possible values**: `true`, `false`
1544 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1546 #### `false` (default):
1570 See also [`reorder_imports`](#reorder_imports).
1572 ## `reorder_extern_crates`
1574 Reorder `extern crate` statements alphabetically
1576 - **Default value**: `true`
1577 - **Possible values**: `true`, `false`
1579 #### `true` (default):
1597 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1599 ## `reorder_extern_crates_in_group`
1601 Reorder `extern crate` statements in group
1603 - **Default value**: `true`
1604 - **Possible values**: `true`, `false`
1606 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1608 #### `true` (default):
1632 See also [`reorder_extern_crates`](#reorder_extern_crates).
1636 Report `TODO` items in comments.
1638 - **Default value**: `"Never"`
1639 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1641 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1642 it contains a `#X` (with `X` being a number) in parentheses following the
1643 `TODO`, `"Unnumbered"` will ignore it.
1645 See also [`report_fixme`](#report_fixme).
1649 Report `FIXME` items in comments.
1651 - **Default value**: `"Never"`
1652 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1654 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1655 it contains a `#X` (with `X` being a number) in parentheses following the
1656 `FIXME`, `"Unnumbered"` will ignore it.
1658 See also [`report_todo`](#report_todo).
1660 ## `single_line_if_else_max_width`
1662 Maximum line length for single line if-else expressions.
1664 - **Default value**: `50`
1665 - **Possible values**: any positive integer
1667 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1669 #### Lines shorter than `single_line_if_else_max_width`:
1671 let lorem = if ipsum { dolor } else { sit };
1674 #### Lines longer than `single_line_if_else_max_width`:
1676 let lorem = if ipsum {
1683 See also: [`control_brace_style`](#control_brace_style).
1687 Don't reformat out of line modules
1689 - **Default value**: `false`
1690 - **Possible values**: `true`, `false`
1692 ## `space_after_bound_colon`
1694 Leave a space after the colon in a trait or lifetime bound
1696 - **Default value**: `true`
1697 - **Possible values**: `true`, `false`
1699 #### `true` (default):
1702 fn lorem<T: Eq>(t: T) {
1710 fn lorem<T:Eq>(t: T) {
1715 See also: [`space_before_bound`](#space_before_bound).
1717 ## `struct_field_align_threshold`
1719 The maximum diff of width between struct fields to be aligned with each other.
1721 - **Default value** : 0
1722 - **Possible values**: any positive integer
1744 ## `space_after_struct_lit_field_colon`
1746 Leave a space after the colon in a struct literal field
1748 - **Default value**: `true`
1749 - **Possible values**: `true`, `false`
1751 #### `true` (default):
1769 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1771 ## `space_after_type_annotation_colon`
1773 Leave a space after the colon in a type annotation
1775 - **Default value**: `true`
1776 - **Possible values**: `true`, `false`
1778 #### `true` (default):
1781 fn lorem<T: Eq>(t: T) {
1782 let ipsum: Dolor = sit;
1789 fn lorem<T: Eq>(t:T) {
1790 let ipsum:Dolor = sit;
1794 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1796 ## `space_before_bound`
1798 Leave a space before the colon in a trait or lifetime bound
1800 - **Default value**: `false`
1801 - **Possible values**: `true`, `false`
1803 #### `false` (default):
1806 fn lorem<T: Eq>(t: T) {
1807 let ipsum: Dolor = sit;
1814 fn lorem<T : Eq>(t: T) {
1815 let ipsum: Dolor = sit;
1819 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1821 ## `space_before_struct_lit_field_colon`
1823 Leave a space before the colon in a struct literal field
1825 - **Default value**: `false`
1826 - **Possible values**: `true`, `false`
1828 #### `false` (default):
1846 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1848 ## `space_before_type_annotation`
1850 Leave a space before the colon in a type annotation
1852 - **Default value**: `false`
1853 - **Possible values**: `true`, `false`
1855 #### `false` (default):
1858 fn lorem<T: Eq>(t: T) {
1859 let ipsum: Dolor = sit;
1866 fn lorem<T: Eq>(t : T) {
1867 let ipsum : Dolor = sit;
1871 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1873 ## `spaces_around_ranges`
1875 Put spaces around the .. and ... range operators
1877 - **Default value**: `false`
1878 - **Possible values**: `true`, `false`
1880 #### `false` (default):
1889 let lorem = 0 .. 10;
1892 ## `spaces_within_angle_brackets`
1894 Put spaces within non-empty generic arguments
1896 - **Default value**: `false`
1897 - **Possible values**: `true`, `false`
1899 #### `false` (default):
1902 fn lorem<T: Eq>(t: T) {
1910 fn lorem< T: Eq >(t: T) {
1915 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1917 ## `spaces_within_parens`
1919 Put spaces within non-empty parentheses
1921 - **Default value**: `false`
1922 - **Possible values**: `true`, `false`
1924 #### `false` (default):
1927 fn lorem<T: Eq>(t: T) {
1928 let lorem = (ipsum, dolor);
1935 fn lorem<T: Eq>( t: T ) {
1936 let lorem = ( ipsum, dolor );
1940 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1942 ## `spaces_within_square_brackets`
1944 Put spaces within non-empty square brackets
1946 - **Default value**: `false`
1947 - **Possible values**: `true`, `false`
1949 #### `false` (default):
1952 let lorem: [usize; 2] = [ipsum, dolor];
1958 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1961 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1963 ## `struct_lit_multiline_style`
1965 Multiline style on literal structs
1967 - **Default value**: `"PreferSingle"`
1968 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1970 #### `"PreferSingle"` (default):
1973 let lorem = Lorem { ipsum: dolor, sit: amet };
1976 #### `"ForceMulti"`:
1985 See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width).
1987 ## `struct_lit_indent`
1989 Style of struct definition
1991 - **Default value**: `"Block"`
1992 - **Possible values**: `"Block"`, `"Visual"`
1994 #### `"Block"` (default):
2006 let lorem = Lorem { ipsum: dolor,
2010 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
2012 ## `struct_lit_width`
2014 Maximum width in the body of a struct lit before falling back to vertical formatting
2016 - **Default value**: `18`
2017 - **Possible values**: any positive integer
2019 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2021 #### Lines shorter than `struct_lit_width`:
2023 let lorem = Lorem { ipsum: dolor, sit: amet };
2026 #### Lines longer than `struct_lit_width`:
2027 See [`struct_lit_indent`](#struct_lit_indent).
2029 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
2031 ## `struct_variant_width`
2033 Maximum width in the body of a struct variant before falling back to vertical formatting
2035 - **Default value**: `35`
2036 - **Possible values**: any positive integer
2038 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2040 #### Struct variants shorter than `struct_variant_width`:
2045 Sit { amet: Consectetur, adipiscing: Elit },
2049 #### Struct variants longer than `struct_variant_width`:
2063 Number of spaces per tab
2065 - **Default value**: `4`
2066 - **Possible values**: any positive integer
2072 let ipsum = dolor();
2074 "amet consectetur adipiscing elit."
2083 let ipsum = dolor();
2085 "amet consectetur adipiscing elit."
2090 See also: [`hard_tabs`](#hard_tabs).
2092 ## `take_source_hints`
2094 Retain some formatting characteristics from the source code
2096 - **Default value**: `false`
2097 - **Possible values**: `true`, `false`
2099 #### `false` (default):
2104 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2120 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2124 How to handle trailing commas for lists
2126 - **Default value**: `"Vertical"`
2127 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2129 #### `"Vertical"` (default):
2132 let Lorem { ipsum, dolor, sit } = amet;
2146 let Lorem { ipsum, dolor, sit, } = amet;
2160 let Lorem { ipsum, dolor, sit } = amet;
2171 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2173 ## `trailing_semicolon`
2175 Add trailing semicolon after break, continue and return
2177 - **Default value**: `true`
2178 - **Possible values**: `true`, `false`
2180 #### `true` (default):
2194 ## `type_punctuation_density`
2196 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2198 - **Default value**: `"Wide"`
2199 - **Possible values**: `"Compressed"`, `"Wide"`
2201 #### `"Wide"` (default):
2204 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2209 #### `"Compressed"`:
2212 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2217 ## `use_try_shorthand`
2219 Replace uses of the try! macro by the ? shorthand
2221 - **Default value**: `false`
2222 - **Possible values**: `true`, `false`
2224 #### `false` (default):
2227 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2233 let lorem = ipsum.map(|dolor| dolor.sit())?;
2238 Density of a where clause.
2240 - **Default value**: `"Vertical"`
2241 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2243 #### `"Vertical"` (default):
2247 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2251 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2260 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2262 #### `"CompressedIfEmpty"`:
2266 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2269 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2278 #### `"Compressed"`:
2282 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2285 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2296 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2300 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2309 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2311 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2315 Element layout inside a where clause
2317 - **Default value**: `"Vertical"`
2318 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2320 #### `"Vertical"` (default):
2323 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2324 where Ipsum: IpsumDolorSitAmet,
2325 Dolor: DolorSitAmetConsectetur
2330 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2331 where Ipsum: IpsumDolorSitAmet,
2332 Dolor: DolorSitAmetConsectetur,
2333 Sit: SitAmetConsecteturAdipiscing,
2334 Amet: AmetConsecteturAdipiscingElit
2340 #### `"Horizontal"`:
2343 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2344 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2349 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2350 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2356 #### `"HorizontalVertical"`:
2359 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2360 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2365 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2366 where Ipsum: IpsumDolorSitAmet,
2367 Dolor: DolorSitAmetConsectetur,
2368 Sit: SitAmetConsecteturAdipiscing,
2369 Amet: AmetConsecteturAdipiscingElit
2378 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2379 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2384 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2385 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2386 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2392 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2394 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2396 ## `where_pred_indent`
2398 Indentation style of a where predicate
2400 - **Default value**: `"Visual"`
2401 - **Possible values**: `"Block"`, `"Visual"`
2403 #### `"Visual"` (default):
2406 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2419 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2429 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2431 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2435 Overall strategy for where clauses
2437 - **Default value**: `"Rfc"`
2438 - **Possible values**: `"Rfc"`, `"Legacy"`
2440 #### `"Rfc"` (default):
2443 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2457 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2467 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2471 Break comments to fit on the line
2473 - **Default value**: `false`
2474 - **Possible values**: `true`, `false`
2476 #### `false` (default):
2479 // 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.
2485 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2486 // sed do eiusmod tempor incididunt ut labore et dolore
2487 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2488 // exercitation ullamco laboris nisi ut aliquip ex ea
2489 // commodo consequat.
2492 ## `wrap_match_arms`
2494 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2496 - **Default value**: `true`
2497 - **Possible values**: `true`, `false`
2499 #### `true` (default):
2504 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2506 false => println!("{}", sit),
2515 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2516 false => println!("{}", sit),
2520 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2524 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2526 - **Default value**: `"Overwrite"`
2527 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`