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 ## `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_indent` 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 {
369 if let Some(..) = x {
386 while let Some(..) = x {
412 Maximum length of comments. No effect unless`wrap_comments = true`.
414 - **Default value**: `80`
415 - **Possible values**: any positive integer
417 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
419 #### Comments shorter than `comment_width`:
421 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
424 #### Comments longer than `comment_width`:
426 // Lorem ipsum dolor sit amet,
427 // consectetur adipiscing elit.
430 See also [`wrap_comments`](#wrap_comments).
432 ## `condense_wildcard_suffixes`
434 Replace strings of _ wildcards by a single .. in tuple patterns
436 - **Default value**: `false`
437 - **Possible values**: `true`, `false`
439 #### `false` (default):
442 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
448 let (lorem, ipsum, ..) = (1, 2, 3, 4);
453 Indent style for control flow statements
455 - **Default value**: `"Rfc"`
456 - **Possible values**: `"Rfc"`, `"Legacy"`
458 #### `"Rfc"` (default):
479 See also: [`control_brace_style`](#control_brace_style).
481 ## `control_brace_style`
483 Brace style for control flow constructs
485 - **Default value**: `"AlwaysSameLine"`
486 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
488 #### `"AlwaysSameLine"` (default):
498 #### `"AlwaysNextLine"`:
511 #### `"ClosingNextLine"`:
522 ## `disable_all_formatting`
524 Don't reformat anything
526 - **Default value**: `false`
527 - **Possible values**: `true`, `false`
529 ## `error_on_line_overflow`
531 Error if unable to get all lines within `max_width`
533 - **Default value**: `true`
534 - **Possible values**: `true`, `false`
536 See also [`max_width`](#max_width).
538 ## `error_on_line_overflow_comments`
540 Error if unable to get all comment lines within `comment_width`.
542 - **Default value**: `true`
543 - **Possible values**: `true`, `false`
545 See also [`comment_width`](#comment_width).
549 Argument density in functions
551 - **Default value**: `"Tall"`
552 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
554 #### `"Tall"` (default):
558 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
560 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
569 consectetur: Consectetur,
570 adipiscing: Adipiscing,
579 consectetur: Consectetur,
580 adipiscing: Adipiscing,
592 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
594 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
599 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
600 adipiscing: Adipiscing, elit: Elit,
604 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
605 adipiscing: Adipiscing, elit: Elit,
612 #### `"CompressedIfEmpty"`:
616 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
618 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
623 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
624 adipiscing: Adipiscing, elit: Elit,
632 consectetur: Consectetur,
633 adipiscing: Adipiscing,
645 fn lorem(ipsum: Ipsum,
650 fn lorem(ipsum: Ipsum,
657 fn lorem(ipsum: Ipsum,
661 consectetur: Consectetur,
662 adipiscing: Adipiscing,
665 fn lorem(ipsum: Ipsum,
669 consectetur: Consectetur,
670 adipiscing: Adipiscing,
679 Layout of function arguments and tuple structs
681 - **Default value**: `"Block"`
682 - **Possible values**: `"Block"`, `"Visual"`
684 #### `"Block"` (default):
689 fn lorem(ipsum: usize) {}
709 fn lorem(ipsum: usize) {}
711 fn lorem(ipsum: usize,
722 ## `fn_args_paren_newline`
724 If function argument parenthesis goes on a newline
726 - **Default value**: `false`
727 - **Possible values**: `true`, `false`
729 #### `false` (default):
737 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
751 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
758 Brace style for functions
760 - **Default value**: `"SameLineWhere"`
761 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
763 #### `"SameLineWhere"` (default):
770 fn lorem(ipsum: usize) {
774 fn lorem<T>(ipsum: T)
776 T: Add + Sub + Mul + Div,
782 #### `"AlwaysNextLine"`:
790 fn lorem(ipsum: usize)
795 fn lorem<T>(ipsum: T)
797 T: Add + Sub + Mul + Div,
803 #### `"PreferSameLine"`:
810 fn lorem(ipsum: usize) {
814 fn lorem<T>(ipsum: T)
816 T: Add + Sub + Mul + Div, {
823 Indentation for function calls, etc.
825 - **Default value**: `"Block"`
826 - **Possible values**: `"Block"`, `"Visual"`
828 #### `"Block"` (default):
858 Maximum width of the args of a function call before falling back to vertical formatting
860 - **Default value**: `60`
861 - **Possible values**: any positive integer
863 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
865 #### Function call shorter than `fn_call_width`:
867 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
870 #### Function call longer than `fn_call_width`:
872 See [`fn_call_indent`](#fn_call_indent).
874 ## `fn_empty_single_line`
876 Put empty-body functions on a single line
878 - **Default value**: `true`
879 - **Possible values**: `true`, `false`
881 #### `true` (default):
894 See also [`control_brace_style`](#control_brace_style).
896 ## `fn_return_indent`
898 Location of return type in function declaration
900 - **Default value**: `"WithArgs"`
901 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
903 #### `"WithArgs"` (default):
906 fn lorem(ipsum: Ipsum,
910 consectetur: Consectetur,
911 adipiscing: Adipiscing)
920 #### `"WithWhereClause"`:
923 fn lorem(ipsum: Ipsum,
927 consectetur: Consectetur,
928 adipiscing: Adipiscing)
937 **Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`.
941 Put single-expression functions on a single line
943 - **Default value**: `false`
944 - **Possible values**: `true`, `false`
946 #### `false` (default):
949 fn lorem() -> usize {
953 fn lorem() -> usize {
962 fn lorem() -> usize { 42 }
964 fn lorem() -> usize {
970 See also [`control_brace_style`](#control_brace_style).
972 ## `force_explicit_abi`
974 Always print the abi for extern items
976 - **Default value**: `true`
977 - **Possible values**: `true`, `false`
979 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
981 #### `true` (default):
985 pub static lorem: c_int;
993 pub static lorem: c_int;
997 ## `force_format_strings`
999 Always format string literals
1001 - **Default value**: `false`
1002 - **Possible values**: `true`, `false`
1004 See [`format_strings`](#format_strings).
1006 See also [`max_width`](#max_width).
1010 Format string literals where necessary
1012 - **Default value**: `false`
1013 - **Possible values**: `true`, `false`
1015 #### `false` (default):
1018 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
1025 "ipsum dolor sit amet consectetur \
1026 adipiscing elit lorem ipsum dolor sit";
1029 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
1031 ## `generics_indent`
1033 Indentation of generics
1035 - **Default value**: `"Block"`
1036 - **Possible values**: `"Block"`, `"Visual"`
1038 #### `"Block"` (default):
1046 Adipiscing: Eq = usize,
1047 Consectetur: Eq = usize,
1054 adipiscing: Adipiscing,
1055 consectetur: Consectetur,
1065 fn lorem<Ipsum: Eq = usize,
1069 Adipiscing: Eq = usize,
1070 Consectetur: Eq = usize,
1076 adipiscing: Adipiscing,
1077 consectetur: Consectetur,
1086 Use tab characters for indentation, spaces for alignment
1088 - **Default value**: `false`
1089 - **Possible values**: `true`, `false`
1091 #### `false` (default):
1094 fn lorem() -> usize {
1095 42 // spaces before 42
1102 fn lorem() -> usize {
1103 42 // tabs before 42
1107 See also: [`tab_spaces`](#tab_spaces).
1109 ## `impl_empty_single_line`
1111 Put empty-body implementations on a single line
1113 - **Default value**: `true`
1114 - **Possible values**: `true`, `false`
1116 #### `true` (default):
1129 See also [`item_brace_style`](#item_brace_style).
1131 ## `indent_match_arms`
1133 Indent match arms instead of keeping them at the same indentation level as the match keyword
1135 - **Default value**: `true`
1136 - **Possible values**: `true`, `false`
1138 #### `true` (default):
1160 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1164 Indent style of imports
1166 - **Default Value**: `"Visual"`
1167 - **Possible values**: `"Block"`, `"Visual"`
1169 #### `"Visual"` (default):
1187 See also: [`imports_layout`](#imports_layout).
1191 Item layout inside a imports block
1193 - **Default value**: "Mixed"
1194 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1196 #### `"Mixed"` (default):
1199 use foo::{xxx, yyy, zzz};
1201 use foo::{aaa, bbb, ccc,
1205 #### `"Horizontal"`:
1207 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1210 use foo::{xxx, yyy, zzz};
1212 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1215 #### `"HorizontalVertical"`:
1218 use foo::{xxx, yyy, zzz};
1243 ## `item_brace_style`
1245 Brace style for structs and enums
1247 - **Default value**: `"SameLineWhere"`
1248 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1250 #### `"SameLineWhere"` (default):
1264 #### `"AlwaysNextLine"`:
1279 #### `"PreferSameLine"`:
1292 ## `match_arm_forces_newline`
1294 Consistently put match arms (block based or not) in a newline.
1296 - **Default value**: `false`
1297 - **Possible values**: `true`, `false`
1299 #### `false` (default):
1303 // a non-empty block
1310 X2 => println!("ok"),
1318 // a non-empty block
1332 See also: [`wrap_match_arms`](#wrap_match_arms).
1334 ## `match_block_trailing_comma`
1336 Put a trailing comma after a block based match arm (non-block arms are not affected)
1338 - **Default value**: `false`
1339 - **Possible values**: `true`, `false`
1341 #### `false` (default):
1348 Lorem::Dolor => println!("dolor"),
1359 Lorem::Dolor => println!("dolor"),
1363 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1365 ## `match_pattern_separator_break_point`
1367 Put a match sub-patterns' separator (`|`) in front or back.
1369 - **Default value**: `"Back"`
1370 - **Possible values**: `"Back"`, `"Front"`
1372 #### `"Back"` (default):
1394 | Variant::Tag6 => {}
1400 Maximum width of each line
1402 - **Default value**: `100`
1403 - **Possible values**: any positive integer
1405 See also [`error_on_line_overflow`](#error_on_line_overflow).
1409 Merge multiple derives into a single one.
1411 - **Default value**: `true`
1412 - **Possible values**: `true`, `false`
1414 #### `true` (default):
1417 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1424 #[derive(Eq, PartialEq)]
1426 #[derive(Copy, Clone)]
1430 ## `multiline_closure_forces_block`
1432 Force multiline closure bodies to be wrapped in a block
1434 - **Default value**: `false`
1435 - **Possible values**: `false`, `true`
1437 #### `false` (default):
1440 result.and_then(|maybe_value| match maybe_value {
1450 result.and_then(|maybe_value| {
1458 ## `multiline_match_arm_forces_block`
1460 Force multiline match arm bodies to be wrapped in a block
1462 - **Default value**: `false`
1463 - **Possible values**: `false`, `true`
1465 #### `false` (default):
1470 println!("Hello World");
1482 println!("Hello World");
1491 Unix or Windows line endings
1493 - **Default value**: `"Unix"`
1494 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1496 ## `normalize_comments`
1498 Convert /* */ comments to // comments where possible
1500 - **Default value**: `false`
1501 - **Possible values**: `true`, `false`
1503 #### `false` (default):
1507 fn dolor() -> usize {}
1510 fn adipiscing() -> usize {}
1517 fn dolor() -> usize {}
1520 fn adipiscing() -> usize {}
1523 ## `reorder_imported_names`
1525 Reorder lists of names in import statements alphabetically
1527 - **Default value**: `false`
1528 - **Possible values**: `true`, `false`
1530 #### `false` (default):
1533 use super::{lorem, ipsum, dolor, sit};
1539 use super::{dolor, ipsum, lorem, sit};
1542 See also [`reorder_imports`](#reorder_imports).
1544 ## `reorder_imports`
1546 Reorder import statements alphabetically
1548 - **Default value**: `false`
1549 - **Possible values**: `true`, `false`
1551 #### `false` (default):
1569 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1571 ## `reorder_imports_in_group`
1573 Reorder import statements in group
1575 - **Default value**: `false`
1576 - **Possible values**: `true`, `false`
1578 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1580 #### `false` (default):
1604 See also [`reorder_imports`](#reorder_imports).
1606 ## `reorder_extern_crates`
1608 Reorder `extern crate` statements alphabetically
1610 - **Default value**: `true`
1611 - **Possible values**: `true`, `false`
1613 #### `true` (default):
1631 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1633 ## `reorder_extern_crates_in_group`
1635 Reorder `extern crate` statements in group
1637 - **Default value**: `true`
1638 - **Possible values**: `true`, `false`
1640 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1642 #### `true` (default):
1666 See also [`reorder_extern_crates`](#reorder_extern_crates).
1670 Report `TODO` items in comments.
1672 - **Default value**: `"Never"`
1673 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1675 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1676 it contains a `#X` (with `X` being a number) in parentheses following the
1677 `TODO`, `"Unnumbered"` will ignore it.
1679 See also [`report_fixme`](#report_fixme).
1683 Report `FIXME` items in comments.
1685 - **Default value**: `"Never"`
1686 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1688 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1689 it contains a `#X` (with `X` being a number) in parentheses following the
1690 `FIXME`, `"Unnumbered"` will ignore it.
1692 See also [`report_todo`](#report_todo).
1694 ## `single_line_if_else_max_width`
1696 Maximum line length for single line if-else expressions.
1698 - **Default value**: `50`
1699 - **Possible values**: any positive integer
1701 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1703 #### Lines shorter than `single_line_if_else_max_width`:
1705 let lorem = if ipsum { dolor } else { sit };
1708 #### Lines longer than `single_line_if_else_max_width`:
1710 let lorem = if ipsum {
1717 See also: [`control_brace_style`](#control_brace_style).
1721 Don't reformat out of line modules
1723 - **Default value**: `false`
1724 - **Possible values**: `true`, `false`
1726 ## `space_after_bound_colon`
1728 Leave a space after the colon in a trait or lifetime bound
1730 - **Default value**: `true`
1731 - **Possible values**: `true`, `false`
1733 #### `true` (default):
1736 fn lorem<T: Eq>(t: T) {
1744 fn lorem<T:Eq>(t: T) {
1749 See also: [`space_before_bound`](#space_before_bound).
1751 ## `struct_field_align_threshold`
1753 The maximum diff of width between struct fields to be aligned with each other.
1755 - **Default value** : 0
1756 - **Possible values**: any positive integer
1778 ## `space_after_struct_lit_field_colon`
1780 Leave a space after the colon in a struct literal field
1782 - **Default value**: `true`
1783 - **Possible values**: `true`, `false`
1785 #### `true` (default):
1803 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1805 ## `space_after_type_annotation_colon`
1807 Leave a space after the colon in a type annotation
1809 - **Default value**: `true`
1810 - **Possible values**: `true`, `false`
1812 #### `true` (default):
1815 fn lorem<T: Eq>(t: T) {
1816 let ipsum: Dolor = sit;
1823 fn lorem<T: Eq>(t:T) {
1824 let ipsum:Dolor = sit;
1828 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1830 ## `space_before_bound`
1832 Leave a space before the colon in a trait or lifetime bound
1834 - **Default value**: `false`
1835 - **Possible values**: `true`, `false`
1837 #### `false` (default):
1840 fn lorem<T: Eq>(t: T) {
1841 let ipsum: Dolor = sit;
1848 fn lorem<T : Eq>(t: T) {
1849 let ipsum: Dolor = sit;
1853 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1855 ## `space_before_struct_lit_field_colon`
1857 Leave a space before the colon in a struct literal field
1859 - **Default value**: `false`
1860 - **Possible values**: `true`, `false`
1862 #### `false` (default):
1880 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1882 ## `space_before_type_annotation`
1884 Leave a space before the colon in a type annotation
1886 - **Default value**: `false`
1887 - **Possible values**: `true`, `false`
1889 #### `false` (default):
1892 fn lorem<T: Eq>(t: T) {
1893 let ipsum: Dolor = sit;
1900 fn lorem<T: Eq>(t : T) {
1901 let ipsum : Dolor = sit;
1905 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1907 ## `spaces_around_ranges`
1909 Put spaces around the .. and ... range operators
1911 - **Default value**: `false`
1912 - **Possible values**: `true`, `false`
1914 #### `false` (default):
1923 let lorem = 0 .. 10;
1926 ## `spaces_within_angle_brackets`
1928 Put spaces within non-empty generic arguments
1930 - **Default value**: `false`
1931 - **Possible values**: `true`, `false`
1933 #### `false` (default):
1936 fn lorem<T: Eq>(t: T) {
1944 fn lorem< T: Eq >(t: T) {
1949 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1951 ## `spaces_within_parens`
1953 Put spaces within non-empty parentheses
1955 - **Default value**: `false`
1956 - **Possible values**: `true`, `false`
1958 #### `false` (default):
1961 fn lorem<T: Eq>(t: T) {
1962 let lorem = (ipsum, dolor);
1969 fn lorem<T: Eq>( t: T ) {
1970 let lorem = ( ipsum, dolor );
1974 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1976 ## `spaces_within_square_brackets`
1978 Put spaces within non-empty square brackets
1980 - **Default value**: `false`
1981 - **Possible values**: `true`, `false`
1983 #### `false` (default):
1986 let lorem: [usize; 2] = [ipsum, dolor];
1992 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1995 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1997 ## `struct_lit_multiline_style`
1999 Multiline style on literal structs
2001 - **Default value**: `"PreferSingle"`
2002 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
2004 #### `"PreferSingle"` (default):
2007 let lorem = Lorem { ipsum: dolor, sit: amet };
2010 #### `"ForceMulti"`:
2019 See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width).
2021 ## `struct_lit_indent`
2023 Style of struct definition
2025 - **Default value**: `"Block"`
2026 - **Possible values**: `"Block"`, `"Visual"`
2028 #### `"Block"` (default):
2040 let lorem = Lorem { ipsum: dolor,
2044 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
2046 ## `struct_lit_width`
2048 Maximum width in the body of a struct lit before falling back to vertical formatting
2050 - **Default value**: `18`
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 #### Lines shorter than `struct_lit_width`:
2057 let lorem = Lorem { ipsum: dolor, sit: amet };
2060 #### Lines longer than `struct_lit_width`:
2061 See [`struct_lit_indent`](#struct_lit_indent).
2063 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
2065 ## `struct_variant_width`
2067 Maximum width in the body of a struct variant before falling back to vertical formatting
2069 - **Default value**: `35`
2070 - **Possible values**: any positive integer
2072 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2074 #### Struct variants shorter than `struct_variant_width`:
2079 Sit { amet: Consectetur, adipiscing: Elit },
2083 #### Struct variants longer than `struct_variant_width`:
2097 Number of spaces per tab
2099 - **Default value**: `4`
2100 - **Possible values**: any positive integer
2106 let ipsum = dolor();
2108 "amet consectetur adipiscing elit."
2117 let ipsum = dolor();
2119 "amet consectetur adipiscing elit."
2124 See also: [`hard_tabs`](#hard_tabs).
2126 ## `take_source_hints`
2128 Retain some formatting characteristics from the source code
2130 - **Default value**: `false`
2131 - **Possible values**: `true`, `false`
2133 #### `false` (default):
2138 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2154 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2158 How to handle trailing commas for lists
2160 - **Default value**: `"Vertical"`
2161 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2163 #### `"Vertical"` (default):
2166 let Lorem { ipsum, dolor, sit } = amet;
2180 let Lorem { ipsum, dolor, sit, } = amet;
2194 let Lorem { ipsum, dolor, sit } = amet;
2205 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2207 ## `trailing_semicolon`
2209 Add trailing semicolon after break, continue and return
2211 - **Default value**: `true`
2212 - **Possible values**: `true`, `false`
2214 #### `true` (default):
2228 ## `type_punctuation_density`
2230 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2232 - **Default value**: `"Wide"`
2233 - **Possible values**: `"Compressed"`, `"Wide"`
2235 #### `"Wide"` (default):
2238 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2243 #### `"Compressed"`:
2246 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2251 ## `use_try_shorthand`
2253 Replace uses of the try! macro by the ? shorthand
2255 - **Default value**: `false`
2256 - **Possible values**: `true`, `false`
2258 #### `false` (default):
2261 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2267 let lorem = ipsum.map(|dolor| dolor.sit())?;
2272 Density of a where clause.
2274 - **Default value**: `"Vertical"`
2275 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2277 #### `"Vertical"` (default):
2281 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2285 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2294 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2296 #### `"CompressedIfEmpty"`:
2300 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2303 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2312 #### `"Compressed"`:
2316 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2319 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2330 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2334 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2343 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2345 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2349 Element layout inside a where clause
2351 - **Default value**: `"Vertical"`
2352 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2354 #### `"Vertical"` (default):
2357 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2358 where Ipsum: IpsumDolorSitAmet,
2359 Dolor: DolorSitAmetConsectetur
2364 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2365 where Ipsum: IpsumDolorSitAmet,
2366 Dolor: DolorSitAmetConsectetur,
2367 Sit: SitAmetConsecteturAdipiscing,
2368 Amet: AmetConsecteturAdipiscingElit
2374 #### `"Horizontal"`:
2377 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2378 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2383 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2384 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2390 #### `"HorizontalVertical"`:
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,
2401 Dolor: DolorSitAmetConsectetur,
2402 Sit: SitAmetConsecteturAdipiscing,
2403 Amet: AmetConsecteturAdipiscingElit
2412 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2413 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2418 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2419 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2420 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2426 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2428 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2430 ## `where_pred_indent`
2432 Indentation style of a where predicate
2434 - **Default value**: `"Visual"`
2435 - **Possible values**: `"Block"`, `"Visual"`
2437 #### `"Visual"` (default):
2440 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2453 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2463 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2465 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2469 Overall strategy for where clauses
2471 - **Default value**: `"Rfc"`
2472 - **Possible values**: `"Rfc"`, `"Legacy"`
2474 #### `"Rfc"` (default):
2477 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2491 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2501 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2505 Break comments to fit on the line
2507 - **Default value**: `false`
2508 - **Possible values**: `true`, `false`
2510 #### `false` (default):
2513 // 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.
2519 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2520 // sed do eiusmod tempor incididunt ut labore et dolore
2521 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2522 // exercitation ullamco laboris nisi ut aliquip ex ea
2523 // commodo consequat.
2526 ## `wrap_match_arms`
2528 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2530 - **Default value**: `true`
2531 - **Possible values**: `true`, `false`
2533 #### `true` (default):
2538 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2540 false => println!("{}", sit),
2549 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2550 false => println!("{}", sit),
2554 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2558 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2560 - **Default value**: `"Overwrite"`
2561 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`