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 [`indent_style`](#indent_style) 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.
55 Indent on expressions or items.
57 - **Default value**: `"Block"`
58 - **Possible values**: `"Block"`, `"Visual"`
62 #### `"Block"` (default):
79 let lorem = vec!["ipsum",
90 #### `"Block"` (default):
111 See also: [`control_brace_style`](#control_brace_style).
113 ### Function arguments
115 #### `"Block"` (default):
120 fn lorem(ipsum: usize) {}
140 fn lorem(ipsum: usize) {}
142 fn lorem(ipsum: usize,
155 #### `"Block"` (default):
185 #### `"Block"` (default):
193 Adipiscing: Eq = usize,
194 Consectetur: Eq = usize,
201 adipiscing: Adipiscing,
202 consectetur: Consectetur,
212 fn lorem<Ipsum: Eq = usize,
216 Adipiscing: Eq = usize,
217 Consectetur: Eq = usize,
223 adipiscing: Adipiscing,
224 consectetur: Consectetur,
233 #### `"Block"` (default):
245 let lorem = Lorem { ipsum: dolor,
249 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
253 #### `"Block"` (default):
256 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
270 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
280 See also: [`where_density`](#where_density), [`where_layout`](#where_layout).
284 Maximum width of an array literal before falling back to vertical formatting
286 - **Default value**: `60`
287 - **Possible values**: any positive integer
289 **Note:** A value of `0` results in [`indent_style`](#indent_style) being applied regardless of a line's width.
291 #### Lines shorter than `array_width`:
293 let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit"];
296 #### Lines longer than `array_width`:
297 See [`indent_style`](#indent_style).
299 ## `attributes_on_same_line_as_field`
301 Try to put attributes on the same line as fields
303 - **Default value**: `true`
304 - **Possible values**: `true`, `false`
306 #### `true` (default):
310 #[serde(rename = "Ipsum")] ipsum: usize,
311 #[serde(rename = "Dolor")] dolor: usize,
312 #[serde(rename = "Amet")] amet: usize,
320 #[serde(rename = "Ipsum")]
322 #[serde(rename = "Dolor")]
324 #[serde(rename = "Amet")]
329 ## `attributes_on_same_line_as_variant`
331 Try to put attributes on the same line as variants
333 - **Default value**: `true`
334 - **Possible values**: `true`, `false`
336 #### `true` (default):
340 #[serde(skip_serializing)] Ipsum,
341 #[serde(skip_serializing)] Dolor,
342 #[serde(skip_serializing)] Amet,
350 #[serde(skip_serializing)]
352 #[serde(skip_serializing)]
354 #[serde(skip_serializing)]
361 Where to put a binary operator when a binary expression goes multiline.
363 - **Default value**: `"Front"`
364 - **Possible values**: `"Front"`, `"Back"`
366 #### `"Front"` (default):
377 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
378 ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
392 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
393 bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
400 - **Default value**: `"Block"`
401 - **Possible values**: `"Block"`, `"Visual"`
403 #### `"Block"` (default):
418 let lorem = ipsum.dolor()
426 See also [`chain_width`](#chain_width).
430 Maximum length of a chain to fit on a single line
432 - **Default value**: `60`
433 - **Possible values**: any positive integer
435 #### Lines shorter than `chain_width`:
437 let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
440 #### Lines longer than `chain_width`:
441 See [`chain_indent`](#chain_indent).
443 ## `chain_split_single_child`
445 Split a chain with a single child if its length exceeds [`chain_width`](#chain_width).
447 - **Default value**: `false`
448 - **Possible values**: `false`, `true`
450 #### `false` (default):
453 let files = fs::read_dir("tests/coverage/source").expect("Couldn't read source dir");
459 let files = fs::read_dir("tests/coverage/source")
460 .expect("Couldn't read source dir");
463 See also [`chain_width`](#chain_width).
465 ## `combine_control_expr`
467 Combine control expressions with function calls.
469 - **Default value**: `true`
470 - **Possible values**: `true`, `false`
472 #### `true` (default):
484 foo!(if let Some(..) = x {
497 foo!(while let Some(..) = x {
531 if let Some(..) = x {
548 while let Some(..) = x {
574 Maximum length of comments. No effect unless`wrap_comments = true`.
576 - **Default value**: `80`
577 - **Possible values**: any positive integer
579 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
581 #### Comments shorter than `comment_width`:
583 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
586 #### Comments longer than `comment_width`:
588 // Lorem ipsum dolor sit amet,
589 // consectetur adipiscing elit.
592 See also [`wrap_comments`](#wrap_comments).
594 ## `condense_wildcard_suffixes`
596 Replace strings of _ wildcards by a single .. in tuple patterns
598 - **Default value**: `false`
599 - **Possible values**: `true`, `false`
601 #### `false` (default):
604 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
610 let (lorem, ipsum, ..) = (1, 2, 3, 4);
613 ## `control_brace_style`
615 Brace style for control flow constructs
617 - **Default value**: `"AlwaysSameLine"`
618 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
620 #### `"AlwaysSameLine"` (default):
630 #### `"AlwaysNextLine"`:
643 #### `"ClosingNextLine"`:
654 ## `disable_all_formatting`
656 Don't reformat anything
658 - **Default value**: `false`
659 - **Possible values**: `true`, `false`
661 ## `error_on_line_overflow`
663 Error if unable to get all lines within `max_width`
665 - **Default value**: `true`
666 - **Possible values**: `true`, `false`
668 See also [`max_width`](#max_width).
670 ## `error_on_line_overflow_comments`
672 Error if unable to get all comment lines within `comment_width`.
674 - **Default value**: `true`
675 - **Possible values**: `true`, `false`
677 See also [`comment_width`](#comment_width).
681 Argument density in functions
683 - **Default value**: `"Tall"`
684 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
686 #### `"Tall"` (default):
690 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
692 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
701 consectetur: Consectetur,
702 adipiscing: Adipiscing,
711 consectetur: Consectetur,
712 adipiscing: Adipiscing,
724 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
726 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
731 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
732 adipiscing: Adipiscing, elit: Elit,
736 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
737 adipiscing: Adipiscing, elit: Elit,
744 #### `"CompressedIfEmpty"`:
748 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
750 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
755 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
756 adipiscing: Adipiscing, elit: Elit,
764 consectetur: Consectetur,
765 adipiscing: Adipiscing,
777 fn lorem(ipsum: Ipsum,
782 fn lorem(ipsum: Ipsum,
789 fn lorem(ipsum: Ipsum,
793 consectetur: Consectetur,
794 adipiscing: Adipiscing,
797 fn lorem(ipsum: Ipsum,
801 consectetur: Consectetur,
802 adipiscing: Adipiscing,
809 ## `fn_args_paren_newline`
811 If function argument parenthesis goes on a newline
813 - **Default value**: `false`
814 - **Possible values**: `true`, `false`
816 #### `false` (default):
824 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
838 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
845 Brace style for items
847 - **Default value**: `"SameLineWhere"`
848 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
852 #### `"SameLineWhere"` (default):
859 fn lorem(ipsum: usize) {
863 fn lorem<T>(ipsum: T)
865 T: Add + Sub + Mul + Div,
871 #### `"AlwaysNextLine"`:
879 fn lorem(ipsum: usize)
884 fn lorem<T>(ipsum: T)
886 T: Add + Sub + Mul + Div,
892 #### `"PreferSameLine"`:
899 fn lorem(ipsum: usize) {
903 fn lorem<T>(ipsum: T)
905 T: Add + Sub + Mul + Div, {
910 ### Structs and enums
912 #### `"SameLineWhere"` (default):
926 #### `"AlwaysNextLine"`:
941 #### `"PreferSameLine"`:
956 Maximum width of the args of a function call before falling back to vertical formatting
958 - **Default value**: `60`
959 - **Possible values**: any positive integer
961 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
963 #### Function call shorter than `fn_call_width`:
965 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
968 #### Function call longer than `fn_call_width`:
970 See [`indent_style`](#indent_style).
972 ## `fn_empty_single_line`
974 Put empty-body functions on a single line
976 - **Default value**: `true`
977 - **Possible values**: `true`, `false`
979 #### `true` (default):
992 See also [`control_brace_style`](#control_brace_style).
994 ## `fn_return_indent`
996 Location of return type in function declaration
998 - **Default value**: `"WithArgs"`
999 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
1001 #### `"WithArgs"` (default):
1004 fn lorem(ipsum: Ipsum,
1008 consectetur: Consectetur,
1009 adipiscing: Adipiscing)
1018 #### `"WithWhereClause"`:
1021 fn lorem(ipsum: Ipsum,
1025 consectetur: Consectetur,
1026 adipiscing: Adipiscing)
1035 **Note**: This option only takes effect when `indent_style` is set to `"Visual"`.
1039 Put single-expression functions on a single line
1041 - **Default value**: `false`
1042 - **Possible values**: `true`, `false`
1044 #### `false` (default):
1047 fn lorem() -> usize {
1051 fn lorem() -> usize {
1060 fn lorem() -> usize { 42 }
1062 fn lorem() -> usize {
1068 See also [`control_brace_style`](#control_brace_style).
1070 ## `force_explicit_abi`
1072 Always print the abi for extern items
1074 - **Default value**: `true`
1075 - **Possible values**: `true`, `false`
1077 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
1079 #### `true` (default):
1083 pub static lorem: c_int;
1091 pub static lorem: c_int;
1095 ## `force_format_strings`
1097 Always format string literals
1099 - **Default value**: `false`
1100 - **Possible values**: `true`, `false`
1102 See [`format_strings`](#format_strings).
1104 See also [`max_width`](#max_width).
1108 Format string literals where necessary
1110 - **Default value**: `false`
1111 - **Possible values**: `true`, `false`
1113 #### `false` (default):
1116 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
1123 "ipsum dolor sit amet consectetur \
1124 adipiscing elit lorem ipsum dolor sit";
1127 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
1131 Use tab characters for indentation, spaces for alignment
1133 - **Default value**: `false`
1134 - **Possible values**: `true`, `false`
1136 #### `false` (default):
1139 fn lorem() -> usize {
1140 42 // spaces before 42
1147 fn lorem() -> usize {
1148 42 // tabs before 42
1152 See also: [`tab_spaces`](#tab_spaces).
1154 ## `impl_empty_single_line`
1156 Put empty-body implementations on a single line
1158 - **Default value**: `true`
1159 - **Possible values**: `true`, `false`
1161 #### `true` (default):
1174 See also [`brace_style`](#brace_style).
1176 ## `indent_match_arms`
1178 Indent match arms instead of keeping them at the same indentation level as the match keyword
1180 - **Default value**: `true`
1181 - **Possible values**: `true`, `false`
1183 #### `true` (default):
1205 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1209 Indent style of imports
1211 - **Default Value**: `"Visual"`
1212 - **Possible values**: `"Block"`, `"Visual"`
1214 #### `"Visual"` (default):
1232 See also: [`imports_layout`](#imports_layout).
1236 Item layout inside a imports block
1238 - **Default value**: "Mixed"
1239 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1241 #### `"Mixed"` (default):
1244 use foo::{xxx, yyy, zzz};
1246 use foo::{aaa, bbb, ccc,
1250 #### `"Horizontal"`:
1252 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1255 use foo::{xxx, yyy, zzz};
1257 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1260 #### `"HorizontalVertical"`:
1263 use foo::{xxx, yyy, zzz};
1288 ## `match_arm_forces_newline`
1290 Consistently put match arms (block based or not) in a newline.
1292 - **Default value**: `false`
1293 - **Possible values**: `true`, `false`
1295 #### `false` (default):
1299 // a non-empty block
1306 X2 => println!("ok"),
1314 // a non-empty block
1328 See also: [`wrap_match_arms`](#wrap_match_arms).
1330 ## `match_block_trailing_comma`
1332 Put a trailing comma after a block based match arm (non-block arms are not affected)
1334 - **Default value**: `false`
1335 - **Possible values**: `true`, `false`
1337 #### `false` (default):
1344 Lorem::Dolor => println!("dolor"),
1355 Lorem::Dolor => println!("dolor"),
1359 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1361 ## `match_pattern_separator_break_point`
1363 Put a match sub-patterns' separator (`|`) in front or back.
1365 - **Default value**: `"Back"`
1366 - **Possible values**: `"Back"`, `"Front"`
1368 #### `"Back"` (default):
1390 | Variant::Tag6 => {}
1396 Maximum width of each line
1398 - **Default value**: `100`
1399 - **Possible values**: any positive integer
1401 See also [`error_on_line_overflow`](#error_on_line_overflow).
1405 Merge multiple derives into a single one.
1407 - **Default value**: `true`
1408 - **Possible values**: `true`, `false`
1410 #### `true` (default):
1413 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1420 #[derive(Eq, PartialEq)]
1422 #[derive(Copy, Clone)]
1426 ## `multiline_closure_forces_block`
1428 Force multiline closure bodies to be wrapped in a block
1430 - **Default value**: `false`
1431 - **Possible values**: `false`, `true`
1433 #### `false` (default):
1436 result.and_then(|maybe_value| match maybe_value {
1446 result.and_then(|maybe_value| {
1454 ## `multiline_match_arm_forces_block`
1456 Force multiline match arm bodies to be wrapped in a block
1458 - **Default value**: `false`
1459 - **Possible values**: `false`, `true`
1461 #### `false` (default):
1466 println!("Hello World");
1478 println!("Hello World");
1487 Unix or Windows line endings
1489 - **Default value**: `"Unix"`
1490 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1492 ## `normalize_comments`
1494 Convert /* */ comments to // comments where possible
1496 - **Default value**: `false`
1497 - **Possible values**: `true`, `false`
1499 #### `false` (default):
1503 fn dolor() -> usize {}
1506 fn adipiscing() -> usize {}
1513 fn dolor() -> usize {}
1516 fn adipiscing() -> usize {}
1519 ## `reorder_imported_names`
1521 Reorder lists of names in import statements alphabetically
1523 - **Default value**: `false`
1524 - **Possible values**: `true`, `false`
1526 #### `false` (default):
1529 use super::{lorem, ipsum, dolor, sit};
1535 use super::{dolor, ipsum, lorem, sit};
1538 See also [`reorder_imports`](#reorder_imports).
1540 ## `reorder_imports`
1542 Reorder import statements alphabetically
1544 - **Default value**: `false`
1545 - **Possible values**: `true`, `false`
1547 #### `false` (default):
1565 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1567 ## `reorder_imports_in_group`
1569 Reorder import statements in group
1571 - **Default value**: `false`
1572 - **Possible values**: `true`, `false`
1574 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1576 #### `false` (default):
1600 See also [`reorder_imports`](#reorder_imports).
1602 ## `reorder_extern_crates`
1604 Reorder `extern crate` statements alphabetically
1606 - **Default value**: `true`
1607 - **Possible values**: `true`, `false`
1609 #### `true` (default):
1627 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1629 ## `reorder_extern_crates_in_group`
1631 Reorder `extern crate` statements in group
1633 - **Default value**: `true`
1634 - **Possible values**: `true`, `false`
1636 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1638 #### `true` (default):
1662 See also [`reorder_extern_crates`](#reorder_extern_crates).
1666 Report `TODO` items in comments.
1668 - **Default value**: `"Never"`
1669 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1671 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1672 it contains a `#X` (with `X` being a number) in parentheses following the
1673 `TODO`, `"Unnumbered"` will ignore it.
1675 See also [`report_fixme`](#report_fixme).
1679 Report `FIXME` items in comments.
1681 - **Default value**: `"Never"`
1682 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1684 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1685 it contains a `#X` (with `X` being a number) in parentheses following the
1686 `FIXME`, `"Unnumbered"` will ignore it.
1688 See also [`report_todo`](#report_todo).
1690 ## `single_line_if_else_max_width`
1692 Maximum line length for single line if-else expressions.
1694 - **Default value**: `50`
1695 - **Possible values**: any positive integer
1697 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1699 #### Lines shorter than `single_line_if_else_max_width`:
1701 let lorem = if ipsum { dolor } else { sit };
1704 #### Lines longer than `single_line_if_else_max_width`:
1706 let lorem = if ipsum {
1713 See also: [`control_brace_style`](#control_brace_style).
1717 Don't reformat out of line modules
1719 - **Default value**: `false`
1720 - **Possible values**: `true`, `false`
1722 ## `space_after_colon`
1724 Leave a space after the colon.
1726 - **Default value**: `true`
1727 - **Possible values**: `true`, `false`
1729 #### `true` (default):
1732 fn lorem<T: Eq>(t: T) {
1733 let lorem: Dolor = Lorem {
1743 fn lorem<T:Eq>(t:T) {
1744 let lorem:Dolor = Lorem {
1751 See also: [`space_before_colon`](#space_before_colon).
1753 ## `space_before_colon`
1755 Leave a space before the colon.
1757 - **Default value**: `false`
1758 - **Possible values**: `true`, `false`
1760 #### `false` (default):
1763 fn lorem<T: Eq>(t: T) {
1764 let lorem: Dolor = Lorem {
1774 fn lorem<T : Eq>(t : T) {
1775 let lorem : Dolor = Lorem {
1782 See also: [`space_after_colon`](#space_after_colon).
1784 ## `struct_field_align_threshold`
1786 The maximum diff of width between struct fields to be aligned with each other.
1788 - **Default value** : 0
1789 - **Possible values**: any positive integer
1813 ## `spaces_around_ranges`
1815 Put spaces around the .. and ... range operators
1817 - **Default value**: `false`
1818 - **Possible values**: `true`, `false`
1820 #### `false` (default):
1829 let lorem = 0 .. 10;
1832 ## `spaces_within_parens_and_brackets`
1834 Put spaces within non-empty generic arguments
1836 - **Default value**: `false`
1837 - **Possible values**: `true`, `false`
1839 #### `false` (default):
1842 fn lorem<T: Eq>(t: T) {
1850 fn lorem< T: Eq >(t: T) {
1855 See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
1857 ## `spaces_within_parens_and_brackets`
1859 Put spaces within non-empty parentheses
1861 - **Default value**: `false`
1862 - **Possible values**: `true`, `false`
1864 #### `false` (default):
1867 fn lorem<T: Eq>(t: T) {
1868 let lorem = (ipsum, dolor);
1875 fn lorem<T: Eq>( t: T ) {
1876 let lorem = ( ipsum, dolor );
1880 See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
1882 ## `spaces_within_parens_and_brackets`
1884 Put spaces within non-empty square brackets
1886 - **Default value**: `false`
1887 - **Possible values**: `true`, `false`
1889 #### `false` (default):
1892 let lorem: [usize; 2] = [ipsum, dolor];
1898 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1901 See also: [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets), [`spaces_within_parens_and_brackets`](#spaces_within_parens_and_brackets).
1903 ## `struct_lit_multiline_style`
1905 Multiline style on literal structs
1907 - **Default value**: `"PreferSingle"`
1908 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1910 #### `"PreferSingle"` (default):
1913 let lorem = Lorem { ipsum: dolor, sit: amet };
1916 #### `"ForceMulti"`:
1925 See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
1927 ## `struct_lit_width`
1929 Maximum width in the body of a struct lit before falling back to vertical formatting
1931 - **Default value**: `18`
1932 - **Possible values**: any positive integer
1934 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1936 #### Lines shorter than `struct_lit_width`:
1938 let lorem = Lorem { ipsum: dolor, sit: amet };
1941 #### Lines longer than `struct_lit_width`:
1942 See [`indent_style`](#indent_style).
1944 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
1946 ## `struct_variant_width`
1948 Maximum width in the body of a struct variant before falling back to vertical formatting
1950 - **Default value**: `35`
1951 - **Possible values**: any positive integer
1953 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1955 #### Struct variants shorter than `struct_variant_width`:
1960 Sit { amet: Consectetur, adipiscing: Elit },
1964 #### Struct variants longer than `struct_variant_width`:
1978 Number of spaces per tab
1980 - **Default value**: `4`
1981 - **Possible values**: any positive integer
1987 let ipsum = dolor();
1989 "amet consectetur adipiscing elit."
1998 let ipsum = dolor();
2000 "amet consectetur adipiscing elit."
2005 See also: [`hard_tabs`](#hard_tabs).
2007 ## `take_source_hints`
2009 Retain some formatting characteristics from the source code
2011 - **Default value**: `false`
2012 - **Possible values**: `true`, `false`
2014 #### `false` (default):
2019 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2035 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2039 How to handle trailing commas for lists
2041 - **Default value**: `"Vertical"`
2042 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2044 #### `"Vertical"` (default):
2047 let Lorem { ipsum, dolor, sit } = amet;
2061 let Lorem { ipsum, dolor, sit, } = amet;
2075 let Lorem { ipsum, dolor, sit } = amet;
2086 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2088 ## `trailing_semicolon`
2090 Add trailing semicolon after break, continue and return
2092 - **Default value**: `true`
2093 - **Possible values**: `true`, `false`
2095 #### `true` (default):
2109 ## `type_punctuation_density`
2111 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2113 - **Default value**: `"Wide"`
2114 - **Possible values**: `"Compressed"`, `"Wide"`
2116 #### `"Wide"` (default):
2119 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2124 #### `"Compressed"`:
2127 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2132 ## `use_try_shorthand`
2134 Replace uses of the try! macro by the ? shorthand
2136 - **Default value**: `false`
2137 - **Possible values**: `true`, `false`
2139 #### `false` (default):
2142 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2148 let lorem = ipsum.map(|dolor| dolor.sit())?;
2153 Density of a where clause.
2155 - **Default value**: `"Vertical"`
2156 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2158 #### `"Vertical"` (default):
2162 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2166 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2175 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2177 #### `"CompressedIfEmpty"`:
2181 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2184 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2193 #### `"Compressed"`:
2197 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2200 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2211 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2215 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2224 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2226 See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
2230 Element layout inside a where clause
2232 - **Default value**: `"Vertical"`
2233 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2235 #### `"Vertical"` (default):
2238 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2239 where Ipsum: IpsumDolorSitAmet,
2240 Dolor: DolorSitAmetConsectetur
2245 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2246 where Ipsum: IpsumDolorSitAmet,
2247 Dolor: DolorSitAmetConsectetur,
2248 Sit: SitAmetConsecteturAdipiscing,
2249 Amet: AmetConsecteturAdipiscingElit
2255 #### `"Horizontal"`:
2258 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2259 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2264 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2265 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2271 #### `"HorizontalVertical"`:
2274 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2275 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2280 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2281 where Ipsum: IpsumDolorSitAmet,
2282 Dolor: DolorSitAmetConsectetur,
2283 Sit: SitAmetConsecteturAdipiscing,
2284 Amet: AmetConsecteturAdipiscingElit
2293 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2294 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2299 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2300 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2301 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2307 See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
2311 Break comments to fit on the line
2313 - **Default value**: `false`
2314 - **Possible values**: `true`, `false`
2316 #### `false` (default):
2319 // 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.
2325 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2326 // sed do eiusmod tempor incididunt ut labore et dolore
2327 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2328 // exercitation ullamco laboris nisi ut aliquip ex ea
2329 // commodo consequat.
2332 ## `wrap_match_arms`
2334 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2336 - **Default value**: `true`
2337 - **Possible values**: `true`, `false`
2339 #### `true` (default):
2344 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2346 false => println!("{}", sit),
2355 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2356 false => println!("{}", sit),
2360 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2364 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2366 - **Default value**: `"Overwrite"`
2367 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`