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);
615 Indent style for control flow statements
617 - **Default value**: `"Rfc"`
618 - **Possible values**: `"Rfc"`, `"Legacy"`
620 ## `control_brace_style`
622 Brace style for control flow constructs
624 - **Default value**: `"AlwaysSameLine"`
625 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
627 #### `"AlwaysSameLine"` (default):
637 #### `"AlwaysNextLine"`:
650 #### `"ClosingNextLine"`:
661 ## `disable_all_formatting`
663 Don't reformat anything
665 - **Default value**: `false`
666 - **Possible values**: `true`, `false`
668 ## `error_on_line_overflow`
670 Error if unable to get all lines within `max_width`
672 - **Default value**: `true`
673 - **Possible values**: `true`, `false`
675 See also [`max_width`](#max_width).
677 ## `error_on_line_overflow_comments`
679 Error if unable to get all comment lines within `comment_width`.
681 - **Default value**: `true`
682 - **Possible values**: `true`, `false`
684 See also [`comment_width`](#comment_width).
688 Argument density in functions
690 - **Default value**: `"Tall"`
691 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
693 #### `"Tall"` (default):
697 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
699 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
708 consectetur: Consectetur,
709 adipiscing: Adipiscing,
718 consectetur: Consectetur,
719 adipiscing: Adipiscing,
731 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
733 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
738 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
739 adipiscing: Adipiscing, elit: Elit,
743 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
744 adipiscing: Adipiscing, elit: Elit,
751 #### `"CompressedIfEmpty"`:
755 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
757 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
762 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
763 adipiscing: Adipiscing, elit: Elit,
771 consectetur: Consectetur,
772 adipiscing: Adipiscing,
784 fn lorem(ipsum: Ipsum,
789 fn lorem(ipsum: Ipsum,
796 fn lorem(ipsum: Ipsum,
800 consectetur: Consectetur,
801 adipiscing: Adipiscing,
804 fn lorem(ipsum: Ipsum,
808 consectetur: Consectetur,
809 adipiscing: Adipiscing,
816 ## `fn_args_paren_newline`
818 If function argument parenthesis goes on a newline
820 - **Default value**: `false`
821 - **Possible values**: `true`, `false`
823 #### `false` (default):
831 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
845 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
852 Brace style for functions
854 - **Default value**: `"SameLineWhere"`
855 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
857 #### `"SameLineWhere"` (default):
864 fn lorem(ipsum: usize) {
868 fn lorem<T>(ipsum: T)
870 T: Add + Sub + Mul + Div,
876 #### `"AlwaysNextLine"`:
884 fn lorem(ipsum: usize)
889 fn lorem<T>(ipsum: T)
891 T: Add + Sub + Mul + Div,
897 #### `"PreferSameLine"`:
904 fn lorem(ipsum: usize) {
908 fn lorem<T>(ipsum: T)
910 T: Add + Sub + Mul + Div, {
917 Maximum width of the args of a function call before falling back to vertical formatting
919 - **Default value**: `60`
920 - **Possible values**: any positive integer
922 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
924 #### Function call shorter than `fn_call_width`:
926 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
929 #### Function call longer than `fn_call_width`:
931 See [`indent_style`](#indent_style).
933 ## `fn_empty_single_line`
935 Put empty-body functions on a single line
937 - **Default value**: `true`
938 - **Possible values**: `true`, `false`
940 #### `true` (default):
953 See also [`control_brace_style`](#control_brace_style).
955 ## `fn_return_indent`
957 Location of return type in function declaration
959 - **Default value**: `"WithArgs"`
960 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
962 #### `"WithArgs"` (default):
965 fn lorem(ipsum: Ipsum,
969 consectetur: Consectetur,
970 adipiscing: Adipiscing)
979 #### `"WithWhereClause"`:
982 fn lorem(ipsum: Ipsum,
986 consectetur: Consectetur,
987 adipiscing: Adipiscing)
996 **Note**: This option only takes effect when `indent_style` is set to `"Visual"`.
1000 Put single-expression functions on a single line
1002 - **Default value**: `false`
1003 - **Possible values**: `true`, `false`
1005 #### `false` (default):
1008 fn lorem() -> usize {
1012 fn lorem() -> usize {
1021 fn lorem() -> usize { 42 }
1023 fn lorem() -> usize {
1029 See also [`control_brace_style`](#control_brace_style).
1031 ## `force_explicit_abi`
1033 Always print the abi for extern items
1035 - **Default value**: `true`
1036 - **Possible values**: `true`, `false`
1038 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
1040 #### `true` (default):
1044 pub static lorem: c_int;
1052 pub static lorem: c_int;
1056 ## `force_format_strings`
1058 Always format string literals
1060 - **Default value**: `false`
1061 - **Possible values**: `true`, `false`
1063 See [`format_strings`](#format_strings).
1065 See also [`max_width`](#max_width).
1069 Format string literals where necessary
1071 - **Default value**: `false`
1072 - **Possible values**: `true`, `false`
1074 #### `false` (default):
1077 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
1084 "ipsum dolor sit amet consectetur \
1085 adipiscing elit lorem ipsum dolor sit";
1088 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
1092 Use tab characters for indentation, spaces for alignment
1094 - **Default value**: `false`
1095 - **Possible values**: `true`, `false`
1097 #### `false` (default):
1100 fn lorem() -> usize {
1101 42 // spaces before 42
1108 fn lorem() -> usize {
1109 42 // tabs before 42
1113 See also: [`tab_spaces`](#tab_spaces).
1115 ## `impl_empty_single_line`
1117 Put empty-body implementations on a single line
1119 - **Default value**: `true`
1120 - **Possible values**: `true`, `false`
1122 #### `true` (default):
1135 See also [`item_brace_style`](#item_brace_style).
1137 ## `indent_match_arms`
1139 Indent match arms instead of keeping them at the same indentation level as the match keyword
1141 - **Default value**: `true`
1142 - **Possible values**: `true`, `false`
1144 #### `true` (default):
1166 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1170 Indent style of imports
1172 - **Default Value**: `"Visual"`
1173 - **Possible values**: `"Block"`, `"Visual"`
1175 #### `"Visual"` (default):
1193 See also: [`imports_layout`](#imports_layout).
1197 Item layout inside a imports block
1199 - **Default value**: "Mixed"
1200 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1202 #### `"Mixed"` (default):
1205 use foo::{xxx, yyy, zzz};
1207 use foo::{aaa, bbb, ccc,
1211 #### `"Horizontal"`:
1213 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1216 use foo::{xxx, yyy, zzz};
1218 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1221 #### `"HorizontalVertical"`:
1224 use foo::{xxx, yyy, zzz};
1249 ## `item_brace_style`
1251 Brace style for structs and enums
1253 - **Default value**: `"SameLineWhere"`
1254 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1256 #### `"SameLineWhere"` (default):
1270 #### `"AlwaysNextLine"`:
1285 #### `"PreferSameLine"`:
1298 ## `match_arm_forces_newline`
1300 Consistently put match arms (block based or not) in a newline.
1302 - **Default value**: `false`
1303 - **Possible values**: `true`, `false`
1305 #### `false` (default):
1309 // a non-empty block
1316 X2 => println!("ok"),
1324 // a non-empty block
1338 See also: [`wrap_match_arms`](#wrap_match_arms).
1340 ## `match_block_trailing_comma`
1342 Put a trailing comma after a block based match arm (non-block arms are not affected)
1344 - **Default value**: `false`
1345 - **Possible values**: `true`, `false`
1347 #### `false` (default):
1354 Lorem::Dolor => println!("dolor"),
1365 Lorem::Dolor => println!("dolor"),
1369 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1371 ## `match_pattern_separator_break_point`
1373 Put a match sub-patterns' separator (`|`) in front or back.
1375 - **Default value**: `"Back"`
1376 - **Possible values**: `"Back"`, `"Front"`
1378 #### `"Back"` (default):
1400 | Variant::Tag6 => {}
1406 Maximum width of each line
1408 - **Default value**: `100`
1409 - **Possible values**: any positive integer
1411 See also [`error_on_line_overflow`](#error_on_line_overflow).
1415 Merge multiple derives into a single one.
1417 - **Default value**: `true`
1418 - **Possible values**: `true`, `false`
1420 #### `true` (default):
1423 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1430 #[derive(Eq, PartialEq)]
1432 #[derive(Copy, Clone)]
1436 ## `multiline_closure_forces_block`
1438 Force multiline closure bodies to be wrapped in a block
1440 - **Default value**: `false`
1441 - **Possible values**: `false`, `true`
1443 #### `false` (default):
1446 result.and_then(|maybe_value| match maybe_value {
1456 result.and_then(|maybe_value| {
1464 ## `multiline_match_arm_forces_block`
1466 Force multiline match arm bodies to be wrapped in a block
1468 - **Default value**: `false`
1469 - **Possible values**: `false`, `true`
1471 #### `false` (default):
1476 println!("Hello World");
1488 println!("Hello World");
1497 Unix or Windows line endings
1499 - **Default value**: `"Unix"`
1500 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1502 ## `normalize_comments`
1504 Convert /* */ comments to // comments where possible
1506 - **Default value**: `false`
1507 - **Possible values**: `true`, `false`
1509 #### `false` (default):
1513 fn dolor() -> usize {}
1516 fn adipiscing() -> usize {}
1523 fn dolor() -> usize {}
1526 fn adipiscing() -> usize {}
1529 ## `reorder_imported_names`
1531 Reorder lists of names in import statements alphabetically
1533 - **Default value**: `false`
1534 - **Possible values**: `true`, `false`
1536 #### `false` (default):
1539 use super::{lorem, ipsum, dolor, sit};
1545 use super::{dolor, ipsum, lorem, sit};
1548 See also [`reorder_imports`](#reorder_imports).
1550 ## `reorder_imports`
1552 Reorder import statements alphabetically
1554 - **Default value**: `false`
1555 - **Possible values**: `true`, `false`
1557 #### `false` (default):
1575 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1577 ## `reorder_imports_in_group`
1579 Reorder import statements in group
1581 - **Default value**: `false`
1582 - **Possible values**: `true`, `false`
1584 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1586 #### `false` (default):
1610 See also [`reorder_imports`](#reorder_imports).
1612 ## `reorder_extern_crates`
1614 Reorder `extern crate` statements alphabetically
1616 - **Default value**: `true`
1617 - **Possible values**: `true`, `false`
1619 #### `true` (default):
1637 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1639 ## `reorder_extern_crates_in_group`
1641 Reorder `extern crate` statements in group
1643 - **Default value**: `true`
1644 - **Possible values**: `true`, `false`
1646 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1648 #### `true` (default):
1672 See also [`reorder_extern_crates`](#reorder_extern_crates).
1676 Report `TODO` items in comments.
1678 - **Default value**: `"Never"`
1679 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1681 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1682 it contains a `#X` (with `X` being a number) in parentheses following the
1683 `TODO`, `"Unnumbered"` will ignore it.
1685 See also [`report_fixme`](#report_fixme).
1689 Report `FIXME` items in comments.
1691 - **Default value**: `"Never"`
1692 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1694 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1695 it contains a `#X` (with `X` being a number) in parentheses following the
1696 `FIXME`, `"Unnumbered"` will ignore it.
1698 See also [`report_todo`](#report_todo).
1700 ## `single_line_if_else_max_width`
1702 Maximum line length for single line if-else expressions.
1704 - **Default value**: `50`
1705 - **Possible values**: any positive integer
1707 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1709 #### Lines shorter than `single_line_if_else_max_width`:
1711 let lorem = if ipsum { dolor } else { sit };
1714 #### Lines longer than `single_line_if_else_max_width`:
1716 let lorem = if ipsum {
1723 See also: [`control_brace_style`](#control_brace_style).
1727 Don't reformat out of line modules
1729 - **Default value**: `false`
1730 - **Possible values**: `true`, `false`
1732 ## `space_after_bound_colon`
1734 Leave a space after the colon in a trait or lifetime bound
1736 - **Default value**: `true`
1737 - **Possible values**: `true`, `false`
1739 #### `true` (default):
1742 fn lorem<T: Eq>(t: T) {
1750 fn lorem<T:Eq>(t: T) {
1755 See also: [`space_before_bound`](#space_before_bound).
1757 ## `struct_field_align_threshold`
1759 The maximum diff of width between struct fields to be aligned with each other.
1761 - **Default value** : 0
1762 - **Possible values**: any positive integer
1784 ## `space_after_struct_lit_field_colon`
1786 Leave a space after the colon in a struct literal field
1788 - **Default value**: `true`
1789 - **Possible values**: `true`, `false`
1791 #### `true` (default):
1809 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1811 ## `space_after_type_annotation_colon`
1813 Leave a space after the colon in a type annotation
1815 - **Default value**: `true`
1816 - **Possible values**: `true`, `false`
1818 #### `true` (default):
1821 fn lorem<T: Eq>(t: T) {
1822 let ipsum: Dolor = sit;
1829 fn lorem<T: Eq>(t:T) {
1830 let ipsum:Dolor = sit;
1834 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1836 ## `space_before_bound`
1838 Leave a space before the colon in a trait or lifetime bound
1840 - **Default value**: `false`
1841 - **Possible values**: `true`, `false`
1843 #### `false` (default):
1846 fn lorem<T: Eq>(t: T) {
1847 let ipsum: Dolor = sit;
1854 fn lorem<T : Eq>(t: T) {
1855 let ipsum: Dolor = sit;
1859 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1861 ## `space_before_struct_lit_field_colon`
1863 Leave a space before the colon in a struct literal field
1865 - **Default value**: `false`
1866 - **Possible values**: `true`, `false`
1868 #### `false` (default):
1886 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1888 ## `space_before_type_annotation`
1890 Leave a space before the colon in a type annotation
1892 - **Default value**: `false`
1893 - **Possible values**: `true`, `false`
1895 #### `false` (default):
1898 fn lorem<T: Eq>(t: T) {
1899 let ipsum: Dolor = sit;
1906 fn lorem<T: Eq>(t : T) {
1907 let ipsum : Dolor = sit;
1911 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1913 ## `spaces_around_ranges`
1915 Put spaces around the .. and ... range operators
1917 - **Default value**: `false`
1918 - **Possible values**: `true`, `false`
1920 #### `false` (default):
1929 let lorem = 0 .. 10;
1932 ## `spaces_within_angle_brackets`
1934 Put spaces within non-empty generic arguments
1936 - **Default value**: `false`
1937 - **Possible values**: `true`, `false`
1939 #### `false` (default):
1942 fn lorem<T: Eq>(t: T) {
1950 fn lorem< T: Eq >(t: T) {
1955 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1957 ## `spaces_within_parens`
1959 Put spaces within non-empty parentheses
1961 - **Default value**: `false`
1962 - **Possible values**: `true`, `false`
1964 #### `false` (default):
1967 fn lorem<T: Eq>(t: T) {
1968 let lorem = (ipsum, dolor);
1975 fn lorem<T: Eq>( t: T ) {
1976 let lorem = ( ipsum, dolor );
1980 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1982 ## `spaces_within_square_brackets`
1984 Put spaces within non-empty square brackets
1986 - **Default value**: `false`
1987 - **Possible values**: `true`, `false`
1989 #### `false` (default):
1992 let lorem: [usize; 2] = [ipsum, dolor];
1998 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
2001 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
2003 ## `struct_lit_multiline_style`
2005 Multiline style on literal structs
2007 - **Default value**: `"PreferSingle"`
2008 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
2010 #### `"PreferSingle"` (default):
2013 let lorem = Lorem { ipsum: dolor, sit: amet };
2016 #### `"ForceMulti"`:
2025 See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
2027 ## `struct_lit_width`
2029 Maximum width in the body of a struct lit before falling back to vertical formatting
2031 - **Default value**: `18`
2032 - **Possible values**: any positive integer
2034 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2036 #### Lines shorter than `struct_lit_width`:
2038 let lorem = Lorem { ipsum: dolor, sit: amet };
2041 #### Lines longer than `struct_lit_width`:
2042 See [`indent_style`](#indent_style).
2044 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
2046 ## `struct_variant_width`
2048 Maximum width in the body of a struct variant before falling back to vertical formatting
2050 - **Default value**: `35`
2051 - **Possible values**: any positive integer
2053 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2055 #### Struct variants shorter than `struct_variant_width`:
2060 Sit { amet: Consectetur, adipiscing: Elit },
2064 #### Struct variants longer than `struct_variant_width`:
2078 Number of spaces per tab
2080 - **Default value**: `4`
2081 - **Possible values**: any positive integer
2087 let ipsum = dolor();
2089 "amet consectetur adipiscing elit."
2098 let ipsum = dolor();
2100 "amet consectetur adipiscing elit."
2105 See also: [`hard_tabs`](#hard_tabs).
2107 ## `take_source_hints`
2109 Retain some formatting characteristics from the source code
2111 - **Default value**: `false`
2112 - **Possible values**: `true`, `false`
2114 #### `false` (default):
2119 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2135 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2139 How to handle trailing commas for lists
2141 - **Default value**: `"Vertical"`
2142 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2144 #### `"Vertical"` (default):
2147 let Lorem { ipsum, dolor, sit } = amet;
2161 let Lorem { ipsum, dolor, sit, } = amet;
2175 let Lorem { ipsum, dolor, sit } = amet;
2186 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2188 ## `trailing_semicolon`
2190 Add trailing semicolon after break, continue and return
2192 - **Default value**: `true`
2193 - **Possible values**: `true`, `false`
2195 #### `true` (default):
2209 ## `type_punctuation_density`
2211 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2213 - **Default value**: `"Wide"`
2214 - **Possible values**: `"Compressed"`, `"Wide"`
2216 #### `"Wide"` (default):
2219 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2224 #### `"Compressed"`:
2227 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2232 ## `use_try_shorthand`
2234 Replace uses of the try! macro by the ? shorthand
2236 - **Default value**: `false`
2237 - **Possible values**: `true`, `false`
2239 #### `false` (default):
2242 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2248 let lorem = ipsum.map(|dolor| dolor.sit())?;
2253 Density of a where clause.
2255 - **Default value**: `"Vertical"`
2256 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2258 #### `"Vertical"` (default):
2262 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2266 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2275 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2277 #### `"CompressedIfEmpty"`:
2281 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2284 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2293 #### `"Compressed"`:
2297 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2300 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2311 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2315 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2324 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2326 See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
2330 Element layout inside a where clause
2332 - **Default value**: `"Vertical"`
2333 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2335 #### `"Vertical"` (default):
2338 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2339 where Ipsum: IpsumDolorSitAmet,
2340 Dolor: DolorSitAmetConsectetur
2345 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2346 where Ipsum: IpsumDolorSitAmet,
2347 Dolor: DolorSitAmetConsectetur,
2348 Sit: SitAmetConsecteturAdipiscing,
2349 Amet: AmetConsecteturAdipiscingElit
2355 #### `"Horizontal"`:
2358 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2359 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2364 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2365 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2371 #### `"HorizontalVertical"`:
2374 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2375 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2380 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2381 where Ipsum: IpsumDolorSitAmet,
2382 Dolor: DolorSitAmetConsectetur,
2383 Sit: SitAmetConsecteturAdipiscing,
2384 Amet: AmetConsecteturAdipiscingElit
2393 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2394 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2399 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2400 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2401 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2407 See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
2411 Break comments to fit on the line
2413 - **Default value**: `false`
2414 - **Possible values**: `true`, `false`
2416 #### `false` (default):
2419 // 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.
2425 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2426 // sed do eiusmod tempor incididunt ut labore et dolore
2427 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2428 // exercitation ullamco laboris nisi ut aliquip ex ea
2429 // commodo consequat.
2432 ## `wrap_match_arms`
2434 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2436 - **Default value**: `true`
2437 - **Possible values**: `true`, `false`
2439 #### `true` (default):
2444 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2446 false => println!("{}", sit),
2455 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2456 false => println!("{}", sit),
2460 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2464 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2466 - **Default value**: `"Overwrite"`
2467 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`