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_layout`](#array_layout) 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_layout`](#array_layout) 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_layout`](#array_layout).
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_one_line_max`](#chain_one_line_max).
232 ## `chain_one_line_max`
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_one_line_max`:
241 let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
244 #### Lines longer than `chain_one_line_max`:
245 See [`chain_indent`](#chain_indent).
247 ## `chain_split_single_child`
249 Split a chain with a single child if its length exceeds [`chain_one_line_max`](#chain_one_line_max).
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_one_line_max`](#chain_one_line_max).
269 ## `closure_block_indent_threshold`
271 How many lines a closure must have before it is block indented. -1 means never use block indent.
273 - **Default value**: `7`
274 - **Possible values**: `-1`, or any positive integer
276 #### Closures shorter than `closure_block_indent_threshold`:
287 #### Closures longer than `closure_block_indent_threshold`:
295 println!("consectetur");
296 println!("adipiscing");
301 **Note**: This option only takes effect when `fn_call_style` is set to `"Visual"`.
303 ## `combine_control_expr`
305 Combine control expressions with function calls.
307 - **Default value**: `true`
308 - **Possible values**: `true`, `false`
310 #### `true` (default):
322 foo!(if let Some(..) = x {
335 foo!(while let Some(..) = x {
361 Maximum length of comments. No effect unless`wrap_comments = true`.
363 - **Default value**: `80`
364 - **Possible values**: any positive integer
366 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
368 #### Comments shorter than `comment_width`:
370 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
373 #### Comments longer than `comment_width`:
375 // Lorem ipsum dolor sit amet,
376 // consectetur adipiscing elit.
379 See also [`wrap_comments`](#wrap_comments).
381 ## `condense_wildcard_suffixes`
383 Replace strings of _ wildcards by a single .. in tuple patterns
385 - **Default value**: `false`
386 - **Possible values**: `true`, `false`
388 #### `false` (default):
391 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
397 let (lorem, ipsum, ..) = (1, 2, 3, 4);
402 Indent style for control flow statements
404 - **Default value**: `"Rfc"`
405 - **Possible values**: `"Rfc"`, `"Legacy"`
407 #### `"Rfc"` (default):
428 See also: [`control_brace_style`](#control_brace_style).
430 ## `control_brace_style`
432 Brace style for control flow constructs
434 - **Default value**: `"AlwaysSameLine"`
435 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
437 #### `"AlwaysSameLine"` (default):
447 #### `"AlwaysNextLine"`:
460 #### `"ClosingNextLine"`:
471 ## `disable_all_formatting`
473 Don't reformat anything
475 - **Default value**: `false`
476 - **Possible values**: `true`, `false`
478 ## `error_on_line_overflow`
480 Error if unable to get all lines within max_width
482 - **Default value**: `true`
483 - **Possible values**: `true`, `false`
485 See also [`max_width`](#max_width).
489 Argument density in functions
491 - **Default value**: `"Tall"`
492 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
494 #### `"Tall"` (default):
498 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
500 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
509 consectetur: onsectetur,
510 adipiscing: Adipiscing,
519 consectetur: onsectetur,
520 adipiscing: Adipiscing,
532 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
534 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
539 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
540 adipiscing: Adipiscing, elit: Elit,
544 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
545 adipiscing: Adipiscing, elit: Elit,
552 #### `"CompressedIfEmpty"`:
556 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
558 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
563 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
564 adipiscing: Adipiscing, elit: Elit,
572 consectetur: onsectetur,
573 adipiscing: Adipiscing,
585 fn lorem(ipsum: Ipsum,
590 fn lorem(ipsum: Ipsum,
597 fn lorem(ipsum: Ipsum,
601 consectetur: onsectetur,
602 adipiscing: Adipiscing,
605 fn lorem(ipsum: Ipsum,
609 consectetur: onsectetur,
610 adipiscing: Adipiscing,
619 Layout of function arguments and tuple structs
621 - **Default value**: `"Block"`
622 - **Possible values**: `"Block"`, `"Visual"`
624 #### `"Block"` (default):
629 fn lorem(ipsum: usize) {}
649 fn lorem(ipsum: usize) {}
651 fn lorem(ipsum: usize,
662 ## `fn_args_paren_newline`
664 If function argument parenthesis goes on a newline
666 - **Default value**: `false`
667 - **Possible values**: `true`, `false`
669 #### `false` (default):
677 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
691 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
698 Brace style for functions
700 - **Default value**: `"SameLineWhere"`
701 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
703 #### `"SameLineWhere"` (default):
710 fn lorem(ipsum: usize) {
714 fn lorem<T>(ipsum: T)
716 T: Add + Sub + Mul + Div,
722 #### `"AlwaysNextLine"`:
730 fn lorem(ipsum: usize)
735 fn lorem<T>(ipsum: T)
737 T: Add + Sub + Mul + Div,
743 #### `"PreferSameLine"`:
750 fn lorem(ipsum: usize) {
754 fn lorem<T>(ipsum: T)
756 T: Add + Sub + Mul + Div, {
763 Indentation for function calls, etc.
765 - **Default value**: `"Block"`
766 - **Possible values**: `"Block"`, `"Visual"`
768 #### `"Block"` (default):
798 Maximum width of the args of a function call before falling back to vertical formatting
800 - **Default value**: `60`
801 - **Possible values**: any positive integer
803 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
805 #### Function call shorter than `fn_call_width`:
807 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
810 #### Function call longer than `fn_call_width`:
812 See [`fn_call_style`](#fn_call_style).
814 ## `fn_empty_single_line`
816 Put empty-body functions on a single line
818 - **Default value**: `true`
819 - **Possible values**: `true`, `false`
821 #### `true` (default):
834 See also [`control_brace_style`](#control_brace_style).
836 ## `fn_return_indent`
838 Location of return type in function declaration
840 - **Default value**: `"WithArgs"`
841 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
843 #### `"WithArgs"` (default):
846 fn lorem(ipsum: Ipsum,
850 consectetur: Consectetur,
851 adipiscing: Adipiscing)
860 #### `"WithWhereClause"`:
863 fn lorem(ipsum: Ipsum,
867 consectetur: Consectetur,
868 adipiscing: Adipiscing)
877 **Note**: This option only takes effect when `fn_call_style` is set to `"Visual"`.
881 Put single-expression functions on a single line
883 - **Default value**: `false`
884 - **Possible values**: `true`, `false`
886 #### `false` (default):
889 fn lorem() -> usize {
893 fn lorem() -> usize {
902 fn lorem() -> usize { 42 }
904 fn lorem() -> usize {
910 See also [`control_brace_style`](#control_brace_style).
912 ## `force_explicit_abi`
914 Always print the abi for extern items
916 - **Default value**: `true`
917 - **Possible values**: `true`, `false`
919 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
921 #### `true` (default):
925 pub static lorem: c_int;
933 pub static lorem: c_int;
937 ## `force_format_strings`
939 Always format string literals
941 - **Default value**: `false`
942 - **Possible values**: `true`, `false`
944 See [`format_strings`](#format_strings).
946 See also [`max_width`](#max_width).
950 Format string literals where necessary
952 - **Default value**: `false`
953 - **Possible values**: `true`, `false`
955 #### `false` (default):
958 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
965 "ipsum dolor sit amet consectetur \
966 adipiscing elit lorem ipsum dolor sit";
969 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
973 Indentation of generics
975 - **Default value**: `"Block"`
976 - **Possible values**: `"Block"`, `"Visual"`
978 #### `"Block"` (default):
986 Adipiscing: Eq = usize,
987 Consectetur: Eq = usize,
994 adipiscing: Adipiscing,
995 consectetur: Consectetur,
1005 fn lorem<Ipsum: Eq = usize,
1009 Adipiscing: Eq = usize,
1010 Consectetur: Eq = usize,
1016 adipiscing: Adipiscing,
1017 consectetur: Consectetur,
1026 Use tab characters for indentation, spaces for alignment
1028 - **Default value**: `false`
1029 - **Possible values**: `true`, `false`
1031 #### `false` (default):
1034 fn lorem() -> usize {
1035 42 // spaces before 42
1042 fn lorem() -> usize {
1043 42 // tabs before 42
1047 See also: [`tab_spaces`](#tab_spaces).
1049 ## `impl_empty_single_line`
1051 Put empty-body implementations on a single line
1053 - **Default value**: `true`
1054 - **Possible values**: `true`, `false`
1056 #### `true` (default):
1069 See also [`item_brace_style`](#item_brace_style).
1071 ## `indent_match_arms`
1073 Indent match arms instead of keeping them at the same indentation level as the match keyword
1075 - **Default value**: `true`
1076 - **Possible values**: `true`, `false`
1078 #### `true` (default):
1100 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1104 Indent style of imports
1106 - **Default Value**: `"Visual"`
1107 - **Possible values**: `"Block"`, `"Visual"`
1109 #### `"Visual"` (default):
1127 See also: [`imports_layout`](#imports_layout).
1131 Item layout inside a imports block
1133 - **Default value**: "Mixed"
1134 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1136 #### `"Mixed"` (default):
1139 use foo::{xxx, yyy, zzz};
1141 use foo::{aaa, bbb, ccc,
1145 #### `"Horizontal"`:
1147 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1150 use foo::{xxx, yyy, zzz};
1152 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1155 #### `"HorizontalVertical"`
1158 use foo::{xxx, yyy, zzz};
1183 ## `item_brace_style`
1185 Brace style for structs and enums
1187 - **Default value**: `"SameLineWhere"`
1188 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1190 #### `"SameLineWhere"` (default):
1204 #### `"AlwaysNextLine"`:
1219 #### `"PreferSameLine"`:
1232 ## `match_arm_forces_newline`
1234 Consistently put match arms (block based or not) in a newline.
1236 - **Default value**: `false`
1237 - **Possible values**: `true`, `false`
1239 #### `false` (default):
1243 // a non-empty block
1250 X2 => println!("ok"),
1258 // a non-empty block
1272 See also: [`wrap_match_arms`](#wrap_match_arms).
1274 ## `match_block_trailing_comma`
1276 Put a trailing comma after a block based match arm (non-block arms are not affected)
1278 - **Default value**: `false`
1279 - **Possible values**: `true`, `false`
1281 #### `false` (default):
1288 Lorem::Dolor => println!("dolor"),
1299 Lorem::Dolor => println!("dolor"),
1303 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1305 ## `match_pattern_separator_break_point`
1307 Put a match sub-patterns' separator (`|`) in front or back.
1309 - **Default value**: `"Back"`
1310 - **Possible values**: `"Back"`, `"Front"`
1312 #### `"Back"` (default):
1334 | Variant::Tag6 => {}
1340 Maximum width of each line
1342 - **Default value**: `100`
1343 - **Possible values**: any positive integer
1345 See also [`error_on_line_overflow`](#error_on_line_overflow).
1349 Merge multiple derives into a single one.
1351 - **Default value**: `true`
1352 - **Possible values**: `true`, `false`
1354 #### `true` (default):
1357 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1364 #[derive(Eq, PartialEq)]
1366 #[derive(Copy, Clone)]
1370 ## `multiline_closure_forces_block`
1372 Force multiline closure bodies to be wrapped in a block
1374 - **Default value**: `false`
1375 - **Possible values**: `false`, `true`
1377 #### `false` (default):
1380 result.and_then(|maybe_value| match maybe_value {
1390 result.and_then(|maybe_value| {
1398 ## `multiline_match_arm_forces_block`
1400 Force multiline match arm bodies to be wrapped in a block
1402 - **Default value**: `false`
1403 - **Possible values**: `false`, `true`
1405 #### `false` (default):
1410 println!("Hello World");
1422 println!("Hello World");
1431 Unix or Windows line endings
1433 - **Default value**: `"Unix"`
1434 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1436 ## `normalize_comments`
1438 Convert /* */ comments to // comments where possible
1440 - **Default value**: `false`
1441 - **Possible values**: `true`, `false`
1443 #### `false` (default):
1447 fn dolor() -> usize {}
1450 fn adipiscing() -> usize {}
1457 fn dolor() -> usize {}
1460 fn adipiscing() -> usize {}
1463 ## `reorder_imported_names`
1465 Reorder lists of names in import statements alphabetically
1467 - **Default value**: `false`
1468 - **Possible values**: `true`, `false`
1470 #### `false` (default):
1473 use super::{lorem, ipsum, dolor, sit};
1479 use super::{dolor, ipsum, lorem, sit};
1482 See also [`reorder_imports`](#reorder_imports).
1484 ## `reorder_imports`
1486 Reorder import statements alphabetically
1488 - **Default value**: `false`
1489 - **Possible values**: `true`, `false`
1491 #### `false` (default):
1509 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1511 ## `reorder_imports_in_group`
1513 Reorder import statements in group
1515 - **Default value**: `false`
1516 - **Possible values**: `true`, `false`
1518 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1520 #### `false` (default):
1544 See also [`reorder_imports`](#reorder_imports).
1546 ## `single_line_if_else_max_width`
1548 Maximum line length for single line if-else expressions.
1550 - **Default value**: `50`
1551 - **Possible values**: any positive integer
1553 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1555 #### Lines shorter than `single_line_if_else_max_width`:
1557 let lorem = if ipsum { dolor } else { sit };
1560 #### Lines longer than `single_line_if_else_max_width`:
1562 let lorem = if ipsum {
1569 See also: [`control_brace_style`](#control_brace_style).
1573 Don't reformat out of line modules
1575 - **Default value**: `false`
1576 - **Possible values**: `true`, `false`
1578 ## `space_after_bound_colon`
1580 Leave a space after the colon in a trait or lifetime bound
1582 - **Default value**: `true`
1583 - **Possible values**: `true`, `false`
1585 #### `true` (default):
1588 fn lorem<T: Eq>(t: T) {
1596 fn lorem<T:Eq>(t: T) {
1601 See also: [`space_before_bound`](#space_before_bound).
1603 ## `struct_field_align_threshold`
1605 The maximum diff of width between struct fields to be aligned with each other.
1607 - **Default value** : 0
1608 - **Possible values**: any positive integer
1630 ## `space_after_struct_lit_field_colon`
1632 Leave a space after the colon in a struct literal field
1634 - **Default value**: `true`
1635 - **Possible values**: `true`, `false`
1637 #### `true` (default):
1655 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1657 ## `space_after_type_annotation_colon`
1659 Leave a space after the colon in a type annotation
1661 - **Default value**: `true`
1662 - **Possible values**: `true`, `false`
1664 #### `true` (default):
1667 fn lorem<T: Eq>(t: T) {
1668 let ipsum: Dolor = sit;
1675 fn lorem<T: Eq>(t:T) {
1676 let ipsum:Dolor = sit;
1680 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1682 ## `space_before_bound`
1684 Leave a space before the colon in a trait or lifetime bound
1686 - **Default value**: `false`
1687 - **Possible values**: `true`, `false`
1689 #### `false` (default):
1692 fn lorem<T: Eq>(t: T) {
1693 let ipsum: Dolor = sit;
1700 fn lorem<T : Eq>(t: T) {
1701 let ipsum: Dolor = sit;
1705 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1707 ## `space_before_struct_lit_field_colon`
1709 Leave a space before the colon in a struct literal field
1711 - **Default value**: `false`
1712 - **Possible values**: `true`, `false`
1714 #### `false` (default):
1732 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1734 ## `space_before_type_annotation`
1736 Leave a space before the colon in a type annotation
1738 - **Default value**: `false`
1739 - **Possible values**: `true`, `false`
1741 #### `false` (default):
1744 fn lorem<T: Eq>(t: T) {
1745 let ipsum: Dolor = sit;
1752 fn lorem<T: Eq>(t : T) {
1753 let ipsum : Dolor = sit;
1757 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1759 ## `spaces_around_ranges`
1761 Put spaces around the .. and ... range operators
1763 - **Default value**: `false`
1764 - **Possible values**: `true`, `false`
1766 #### `false` (default):
1775 let lorem = 0 .. 10;
1778 ## `spaces_within_angle_brackets`
1780 Put spaces within non-empty generic arguments
1782 - **Default value**: `false`
1783 - **Possible values**: `true`, `false`
1785 #### `false` (default):
1788 fn lorem<T: Eq>(t: T) {
1796 fn lorem< T: Eq >(t: T) {
1801 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1803 ## `spaces_within_parens`
1805 Put spaces within non-empty parentheses
1807 - **Default value**: `false`
1808 - **Possible values**: `true`, `false`
1810 #### `false` (default):
1813 fn lorem<T: Eq>(t: T) {
1814 let lorem = (ipsum, dolor);
1821 fn lorem<T: Eq>( t: T ) {
1822 let lorem = ( ipsum, dolor );
1826 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1828 ## `spaces_within_square_brackets`
1830 Put spaces within non-empty square brackets
1832 - **Default value**: `false`
1833 - **Possible values**: `true`, `false`
1835 #### `false` (default):
1838 let lorem: [usize; 2] = [ipsum, dolor];
1844 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1847 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1849 ## `struct_lit_multiline_style`
1851 Multiline style on literal structs
1853 - **Default value**: `"PreferSingle"`
1854 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1856 #### `"PreferSingle"` (default):
1859 let lorem = Lorem { ipsum: dolor, sit: amet };
1862 #### `"ForceMulti"`:
1871 See also: [`struct_lit_style`](#struct_lit_style), [`struct_lit_width`](#struct_lit_width).
1873 ## `struct_lit_style`
1875 Style of struct definition
1877 - **Default value**: `"Block"`
1878 - **Possible values**: `"Block"`, `"Visual"`
1880 #### `"Block"` (default):
1892 let lorem = Lorem { ipsum: dolor,
1896 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_style`](#struct_lit_style).
1898 ## `struct_lit_width`
1900 Maximum width in the body of a struct lit before falling back to vertical formatting
1902 - **Default value**: `18`
1903 - **Possible values**: any positive integer
1905 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1907 #### Lines shorter than `struct_lit_width`:
1909 let lorem = Lorem { ipsum: dolor, sit: amet };
1912 #### Lines longer than `struct_lit_width`:
1913 See [`struct_lit_style`](#struct_lit_style).
1915 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_style`](#struct_lit_style).
1917 ## `struct_variant_width`
1919 Maximum width in the body of a struct variant before falling back to vertical formatting
1921 - **Default value**: `35`
1922 - **Possible values**: any positive integer
1924 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1926 #### Struct variants shorter than `struct_variant_width`:
1931 Sit { amet: Consectetur, adipiscing: Elit },
1935 #### Struct variants longer than `struct_variant_width`:
1949 Number of spaces per tab
1951 - **Default value**: `4`
1952 - **Possible values**: any positive integer
1958 let ipsum = dolor();
1960 "amet consectetur adipiscing elit."
1969 let ipsum = dolor();
1971 "amet consectetur adipiscing elit."
1976 See also: [`hard_tabs`](#hard_tabs).
1978 ## `take_source_hints`
1980 Retain some formatting characteristics from the source code
1982 - **Default value**: `false`
1983 - **Possible values**: `true`, `false`
1985 #### `false` (default):
1990 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2006 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2010 How to handle trailing commas for lists
2012 - **Default value**: `"Vertical"`
2013 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2015 #### `"Vertical"` (default):
2018 let Lorem { ipsum, dolor, sit } = amet;
2032 let Lorem { ipsum, dolor, sit, } = amet;
2046 let Lorem { ipsum, dolor, sit } = amet;
2057 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2059 ## `trailing_semicolon`
2061 Add trailing semicolon after break, continue and return
2063 - **Default value**: `true`
2064 - **Possible values**: `true`, `false`
2066 #### `true` (default):
2080 ## `type_punctuation_density`
2082 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2084 - **Default value**: `"Wide"`
2085 - **Possible values**: `"Compressed"`, `"Wide"`
2087 #### `"Wide"` (default):
2090 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2095 #### `"Compressed"`:
2098 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2103 ## `use_try_shorthand`
2105 Replace uses of the try! macro by the ? shorthand
2107 - **Default value**: `false`
2108 - **Possible values**: `true`, `false`
2110 #### `false` (default):
2113 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2119 let lorem = ipsum.map(|dolor| dolor.sit())?;
2124 Density of a where clause.
2126 - **Default value**: `"CompressedIfEmpty"`
2127 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2129 #### `"CompressedIfEmpty"` (default):
2133 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2136 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2145 #### `"Compressed"`:
2149 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2152 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2163 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2167 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2176 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2182 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2185 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2193 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2195 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2199 Element layout inside a where clause
2201 - **Default value**: `"Vertical"`
2202 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2204 #### `"Vertical"` (default):
2207 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2208 where Ipsum: IpsumDolorSitAmet,
2209 Dolor: DolorSitAmetConsectetur
2214 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2215 where Ipsum: IpsumDolorSitAmet,
2216 Dolor: DolorSitAmetConsectetur,
2217 Sit: SitAmetConsecteturAdipiscing,
2218 Amet: AmetConsecteturAdipiscingElit
2224 #### `"Horizontal"`:
2227 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2228 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2233 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2234 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2240 #### `"HorizontalVertical"`:
2243 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2244 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2249 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2250 where Ipsum: IpsumDolorSitAmet,
2251 Dolor: DolorSitAmetConsectetur,
2252 Sit: SitAmetConsecteturAdipiscing,
2253 Amet: AmetConsecteturAdipiscingElit
2262 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2263 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2268 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2269 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2270 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2276 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2278 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2280 ## `where_pred_indent`
2282 Indentation style of a where predicate
2284 - **Default value**: `"Visual"`
2285 - **Possible values**: `"Block"`, `"Visual"`
2287 #### `"Visual"` (default):
2290 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2303 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2313 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2315 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2319 Overall strategy for where clauses
2321 - **Default value**: `"Rfc"`
2322 - **Possible values**: `"Rfc"`, `"Legacy"`
2324 #### `"Rfc"` (default):
2327 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2341 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2351 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2355 Break comments to fit on the line
2357 - **Default value**: `false`
2358 - **Possible values**: `true`, `false`
2360 #### `false` (default):
2363 // 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.
2369 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2370 // sed do eiusmod tempor incididunt ut labore et dolore
2371 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2372 // exercitation ullamco laboris nisi ut aliquip ex ea
2373 // commodo consequat.
2376 ## `wrap_match_arms`
2378 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2380 - **Default value**: `true`
2381 - **Possible values**: `true`, `false`
2383 #### `true` (default):
2388 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2390 false => println!("{}", sit),
2399 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2400 false => println!("{}", sit),
2404 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2408 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2410 - **Default value**: `"Overwrite"`
2411 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`