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 {
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).
487 ## `error_on_line_overflow_comments`
489 Error if unable to get all comment lines within `comment_width`.
491 - **Default value**: `true`
492 - **Possible values**: `true`, `false`
494 See also [`comment_width`](#comment_width).
498 Argument density in functions
500 - **Default value**: `"Tall"`
501 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
503 #### `"Tall"` (default):
507 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
509 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
518 consectetur: Consectetur,
519 adipiscing: Adipiscing,
528 consectetur: Consectetur,
529 adipiscing: Adipiscing,
541 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
543 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
548 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
549 adipiscing: Adipiscing, elit: Elit,
553 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
554 adipiscing: Adipiscing, elit: Elit,
561 #### `"CompressedIfEmpty"`:
565 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
567 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
572 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
573 adipiscing: Adipiscing, elit: Elit,
581 consectetur: Consectetur,
582 adipiscing: Adipiscing,
594 fn lorem(ipsum: Ipsum,
599 fn lorem(ipsum: Ipsum,
606 fn lorem(ipsum: Ipsum,
610 consectetur: Consectetur,
611 adipiscing: Adipiscing,
614 fn lorem(ipsum: Ipsum,
618 consectetur: Consectetur,
619 adipiscing: Adipiscing,
628 Layout of function arguments and tuple structs
630 - **Default value**: `"Block"`
631 - **Possible values**: `"Block"`, `"Visual"`
633 #### `"Block"` (default):
638 fn lorem(ipsum: usize) {}
658 fn lorem(ipsum: usize) {}
660 fn lorem(ipsum: usize,
671 ## `fn_args_paren_newline`
673 If function argument parenthesis goes on a newline
675 - **Default value**: `false`
676 - **Possible values**: `true`, `false`
678 #### `false` (default):
686 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
700 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
707 Brace style for functions
709 - **Default value**: `"SameLineWhere"`
710 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
712 #### `"SameLineWhere"` (default):
719 fn lorem(ipsum: usize) {
723 fn lorem<T>(ipsum: T)
725 T: Add + Sub + Mul + Div,
731 #### `"AlwaysNextLine"`:
739 fn lorem(ipsum: usize)
744 fn lorem<T>(ipsum: T)
746 T: Add + Sub + Mul + Div,
752 #### `"PreferSameLine"`:
759 fn lorem(ipsum: usize) {
763 fn lorem<T>(ipsum: T)
765 T: Add + Sub + Mul + Div, {
772 Indentation for function calls, etc.
774 - **Default value**: `"Block"`
775 - **Possible values**: `"Block"`, `"Visual"`
777 #### `"Block"` (default):
807 Maximum width of the args of a function call before falling back to vertical formatting
809 - **Default value**: `60`
810 - **Possible values**: any positive integer
812 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
814 #### Function call shorter than `fn_call_width`:
816 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
819 #### Function call longer than `fn_call_width`:
821 See [`fn_call_indent`](#fn_call_indent).
823 ## `fn_empty_single_line`
825 Put empty-body functions on a single line
827 - **Default value**: `true`
828 - **Possible values**: `true`, `false`
830 #### `true` (default):
843 See also [`control_brace_style`](#control_brace_style).
845 ## `fn_return_indent`
847 Location of return type in function declaration
849 - **Default value**: `"WithArgs"`
850 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
852 #### `"WithArgs"` (default):
855 fn lorem(ipsum: Ipsum,
859 consectetur: Consectetur,
860 adipiscing: Adipiscing)
869 #### `"WithWhereClause"`:
872 fn lorem(ipsum: Ipsum,
876 consectetur: Consectetur,
877 adipiscing: Adipiscing)
886 **Note**: This option only takes effect when `fn_call_indent` is set to `"Visual"`.
890 Put single-expression functions on a single line
892 - **Default value**: `false`
893 - **Possible values**: `true`, `false`
895 #### `false` (default):
898 fn lorem() -> usize {
902 fn lorem() -> usize {
911 fn lorem() -> usize { 42 }
913 fn lorem() -> usize {
919 See also [`control_brace_style`](#control_brace_style).
921 ## `force_explicit_abi`
923 Always print the abi for extern items
925 - **Default value**: `true`
926 - **Possible values**: `true`, `false`
928 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
930 #### `true` (default):
934 pub static lorem: c_int;
942 pub static lorem: c_int;
946 ## `force_format_strings`
948 Always format string literals
950 - **Default value**: `false`
951 - **Possible values**: `true`, `false`
953 See [`format_strings`](#format_strings).
955 See also [`max_width`](#max_width).
959 Format string literals where necessary
961 - **Default value**: `false`
962 - **Possible values**: `true`, `false`
964 #### `false` (default):
967 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
974 "ipsum dolor sit amet consectetur \
975 adipiscing elit lorem ipsum dolor sit";
978 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
982 Indentation of generics
984 - **Default value**: `"Block"`
985 - **Possible values**: `"Block"`, `"Visual"`
987 #### `"Block"` (default):
995 Adipiscing: Eq = usize,
996 Consectetur: Eq = usize,
1003 adipiscing: Adipiscing,
1004 consectetur: Consectetur,
1014 fn lorem<Ipsum: Eq = usize,
1018 Adipiscing: Eq = usize,
1019 Consectetur: Eq = usize,
1025 adipiscing: Adipiscing,
1026 consectetur: Consectetur,
1035 Use tab characters for indentation, spaces for alignment
1037 - **Default value**: `false`
1038 - **Possible values**: `true`, `false`
1040 #### `false` (default):
1043 fn lorem() -> usize {
1044 42 // spaces before 42
1051 fn lorem() -> usize {
1052 42 // tabs before 42
1056 See also: [`tab_spaces`](#tab_spaces).
1058 ## `impl_empty_single_line`
1060 Put empty-body implementations on a single line
1062 - **Default value**: `true`
1063 - **Possible values**: `true`, `false`
1065 #### `true` (default):
1078 See also [`item_brace_style`](#item_brace_style).
1080 ## `indent_match_arms`
1082 Indent match arms instead of keeping them at the same indentation level as the match keyword
1084 - **Default value**: `true`
1085 - **Possible values**: `true`, `false`
1087 #### `true` (default):
1109 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1113 Indent style of imports
1115 - **Default Value**: `"Visual"`
1116 - **Possible values**: `"Block"`, `"Visual"`
1118 #### `"Visual"` (default):
1136 See also: [`imports_layout`](#imports_layout).
1140 Item layout inside a imports block
1142 - **Default value**: "Mixed"
1143 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1145 #### `"Mixed"` (default):
1148 use foo::{xxx, yyy, zzz};
1150 use foo::{aaa, bbb, ccc,
1154 #### `"Horizontal"`:
1156 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1159 use foo::{xxx, yyy, zzz};
1161 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1164 #### `"HorizontalVertical"`:
1167 use foo::{xxx, yyy, zzz};
1192 ## `item_brace_style`
1194 Brace style for structs and enums
1196 - **Default value**: `"SameLineWhere"`
1197 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1199 #### `"SameLineWhere"` (default):
1213 #### `"AlwaysNextLine"`:
1228 #### `"PreferSameLine"`:
1241 ## `match_arm_forces_newline`
1243 Consistently put match arms (block based or not) in a newline.
1245 - **Default value**: `false`
1246 - **Possible values**: `true`, `false`
1248 #### `false` (default):
1252 // a non-empty block
1259 X2 => println!("ok"),
1267 // a non-empty block
1281 See also: [`wrap_match_arms`](#wrap_match_arms).
1283 ## `match_block_trailing_comma`
1285 Put a trailing comma after a block based match arm (non-block arms are not affected)
1287 - **Default value**: `false`
1288 - **Possible values**: `true`, `false`
1290 #### `false` (default):
1297 Lorem::Dolor => println!("dolor"),
1308 Lorem::Dolor => println!("dolor"),
1312 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1314 ## `match_pattern_separator_break_point`
1316 Put a match sub-patterns' separator (`|`) in front or back.
1318 - **Default value**: `"Back"`
1319 - **Possible values**: `"Back"`, `"Front"`
1321 #### `"Back"` (default):
1343 | Variant::Tag6 => {}
1349 Maximum width of each line
1351 - **Default value**: `100`
1352 - **Possible values**: any positive integer
1354 See also [`error_on_line_overflow`](#error_on_line_overflow).
1358 Merge multiple derives into a single one.
1360 - **Default value**: `true`
1361 - **Possible values**: `true`, `false`
1363 #### `true` (default):
1366 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1373 #[derive(Eq, PartialEq)]
1375 #[derive(Copy, Clone)]
1379 ## `multiline_closure_forces_block`
1381 Force multiline closure bodies to be wrapped in a block
1383 - **Default value**: `false`
1384 - **Possible values**: `false`, `true`
1386 #### `false` (default):
1389 result.and_then(|maybe_value| match maybe_value {
1399 result.and_then(|maybe_value| {
1407 ## `multiline_match_arm_forces_block`
1409 Force multiline match arm bodies to be wrapped in a block
1411 - **Default value**: `false`
1412 - **Possible values**: `false`, `true`
1414 #### `false` (default):
1419 println!("Hello World");
1431 println!("Hello World");
1440 Unix or Windows line endings
1442 - **Default value**: `"Unix"`
1443 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1445 ## `normalize_comments`
1447 Convert /* */ comments to // comments where possible
1449 - **Default value**: `false`
1450 - **Possible values**: `true`, `false`
1452 #### `false` (default):
1456 fn dolor() -> usize {}
1459 fn adipiscing() -> usize {}
1466 fn dolor() -> usize {}
1469 fn adipiscing() -> usize {}
1472 ## `reorder_imported_names`
1474 Reorder lists of names in import statements alphabetically
1476 - **Default value**: `false`
1477 - **Possible values**: `true`, `false`
1479 #### `false` (default):
1482 use super::{lorem, ipsum, dolor, sit};
1488 use super::{dolor, ipsum, lorem, sit};
1491 See also [`reorder_imports`](#reorder_imports).
1493 ## `reorder_imports`
1495 Reorder import statements alphabetically
1497 - **Default value**: `false`
1498 - **Possible values**: `true`, `false`
1500 #### `false` (default):
1518 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1520 ## `reorder_imports_in_group`
1522 Reorder import statements in group
1524 - **Default value**: `false`
1525 - **Possible values**: `true`, `false`
1527 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1529 #### `false` (default):
1553 See also [`reorder_imports`](#reorder_imports).
1555 ## `reorder_extern_crates`
1557 Reorder `extern crate` statements alphabetically
1559 - **Default value**: `true`
1560 - **Possible values**: `true`, `false`
1562 #### `true` (default):
1580 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1582 ## `reorder_extern_crates_in_group`
1584 Reorder `extern crate` statements in group
1586 - **Default value**: `true`
1587 - **Possible values**: `true`, `false`
1589 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1591 #### `true` (default):
1615 See also [`reorder_extern_crates`](#reorder_extern_crates).
1619 Report `TODO` items in comments.
1621 - **Default value**: `"Never"`
1622 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1624 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1625 it contains a `#X` (with `X` being a number) in parentheses following the
1626 `TODO`, `"Unnumbered"` will ignore it.
1628 See also [`report_fixme`](#report_fixme).
1632 Report `FIXME` items in comments.
1634 - **Default value**: `"Never"`
1635 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1637 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1638 it contains a `#X` (with `X` being a number) in parentheses following the
1639 `FIXME`, `"Unnumbered"` will ignore it.
1641 See also [`report_todo`](#report_todo).
1643 ## `single_line_if_else_max_width`
1645 Maximum line length for single line if-else expressions.
1647 - **Default value**: `50`
1648 - **Possible values**: any positive integer
1650 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1652 #### Lines shorter than `single_line_if_else_max_width`:
1654 let lorem = if ipsum { dolor } else { sit };
1657 #### Lines longer than `single_line_if_else_max_width`:
1659 let lorem = if ipsum {
1666 See also: [`control_brace_style`](#control_brace_style).
1670 Don't reformat out of line modules
1672 - **Default value**: `false`
1673 - **Possible values**: `true`, `false`
1675 ## `space_after_bound_colon`
1677 Leave a space after the colon in a trait or lifetime bound
1679 - **Default value**: `true`
1680 - **Possible values**: `true`, `false`
1682 #### `true` (default):
1685 fn lorem<T: Eq>(t: T) {
1693 fn lorem<T:Eq>(t: T) {
1698 See also: [`space_before_bound`](#space_before_bound).
1700 ## `struct_field_align_threshold`
1702 The maximum diff of width between struct fields to be aligned with each other.
1704 - **Default value** : 0
1705 - **Possible values**: any positive integer
1727 ## `space_after_struct_lit_field_colon`
1729 Leave a space after the colon in a struct literal field
1731 - **Default value**: `true`
1732 - **Possible values**: `true`, `false`
1734 #### `true` (default):
1752 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1754 ## `space_after_type_annotation_colon`
1756 Leave a space after the colon in a type annotation
1758 - **Default value**: `true`
1759 - **Possible values**: `true`, `false`
1761 #### `true` (default):
1764 fn lorem<T: Eq>(t: T) {
1765 let ipsum: Dolor = sit;
1772 fn lorem<T: Eq>(t:T) {
1773 let ipsum:Dolor = sit;
1777 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1779 ## `space_before_bound`
1781 Leave a space before the colon in a trait or lifetime bound
1783 - **Default value**: `false`
1784 - **Possible values**: `true`, `false`
1786 #### `false` (default):
1789 fn lorem<T: Eq>(t: T) {
1790 let ipsum: Dolor = sit;
1797 fn lorem<T : Eq>(t: T) {
1798 let ipsum: Dolor = sit;
1802 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1804 ## `space_before_struct_lit_field_colon`
1806 Leave a space before the colon in a struct literal field
1808 - **Default value**: `false`
1809 - **Possible values**: `true`, `false`
1811 #### `false` (default):
1829 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1831 ## `space_before_type_annotation`
1833 Leave a space before the colon in a type annotation
1835 - **Default value**: `false`
1836 - **Possible values**: `true`, `false`
1838 #### `false` (default):
1841 fn lorem<T: Eq>(t: T) {
1842 let ipsum: Dolor = sit;
1849 fn lorem<T: Eq>(t : T) {
1850 let ipsum : Dolor = sit;
1854 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1856 ## `spaces_around_ranges`
1858 Put spaces around the .. and ... range operators
1860 - **Default value**: `false`
1861 - **Possible values**: `true`, `false`
1863 #### `false` (default):
1872 let lorem = 0 .. 10;
1875 ## `spaces_within_angle_brackets`
1877 Put spaces within non-empty generic arguments
1879 - **Default value**: `false`
1880 - **Possible values**: `true`, `false`
1882 #### `false` (default):
1885 fn lorem<T: Eq>(t: T) {
1893 fn lorem< T: Eq >(t: T) {
1898 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1900 ## `spaces_within_parens`
1902 Put spaces within non-empty parentheses
1904 - **Default value**: `false`
1905 - **Possible values**: `true`, `false`
1907 #### `false` (default):
1910 fn lorem<T: Eq>(t: T) {
1911 let lorem = (ipsum, dolor);
1918 fn lorem<T: Eq>( t: T ) {
1919 let lorem = ( ipsum, dolor );
1923 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1925 ## `spaces_within_square_brackets`
1927 Put spaces within non-empty square brackets
1929 - **Default value**: `false`
1930 - **Possible values**: `true`, `false`
1932 #### `false` (default):
1935 let lorem: [usize; 2] = [ipsum, dolor];
1941 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1944 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1946 ## `struct_lit_multiline_style`
1948 Multiline style on literal structs
1950 - **Default value**: `"PreferSingle"`
1951 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1953 #### `"PreferSingle"` (default):
1956 let lorem = Lorem { ipsum: dolor, sit: amet };
1959 #### `"ForceMulti"`:
1968 See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width).
1970 ## `struct_lit_indent`
1972 Style of struct definition
1974 - **Default value**: `"Block"`
1975 - **Possible values**: `"Block"`, `"Visual"`
1977 #### `"Block"` (default):
1989 let lorem = Lorem { ipsum: dolor,
1993 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
1995 ## `struct_lit_width`
1997 Maximum width in the body of a struct lit before falling back to vertical formatting
1999 - **Default value**: `18`
2000 - **Possible values**: any positive integer
2002 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2004 #### Lines shorter than `struct_lit_width`:
2006 let lorem = Lorem { ipsum: dolor, sit: amet };
2009 #### Lines longer than `struct_lit_width`:
2010 See [`struct_lit_indent`](#struct_lit_indent).
2012 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
2014 ## `struct_variant_width`
2016 Maximum width in the body of a struct variant before falling back to vertical formatting
2018 - **Default value**: `35`
2019 - **Possible values**: any positive integer
2021 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2023 #### Struct variants shorter than `struct_variant_width`:
2028 Sit { amet: Consectetur, adipiscing: Elit },
2032 #### Struct variants longer than `struct_variant_width`:
2046 Number of spaces per tab
2048 - **Default value**: `4`
2049 - **Possible values**: any positive integer
2055 let ipsum = dolor();
2057 "amet consectetur adipiscing elit."
2066 let ipsum = dolor();
2068 "amet consectetur adipiscing elit."
2073 See also: [`hard_tabs`](#hard_tabs).
2075 ## `take_source_hints`
2077 Retain some formatting characteristics from the source code
2079 - **Default value**: `false`
2080 - **Possible values**: `true`, `false`
2082 #### `false` (default):
2087 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2103 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2107 How to handle trailing commas for lists
2109 - **Default value**: `"Vertical"`
2110 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2112 #### `"Vertical"` (default):
2115 let Lorem { ipsum, dolor, sit } = amet;
2129 let Lorem { ipsum, dolor, sit, } = amet;
2143 let Lorem { ipsum, dolor, sit } = amet;
2154 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2156 ## `trailing_semicolon`
2158 Add trailing semicolon after break, continue and return
2160 - **Default value**: `true`
2161 - **Possible values**: `true`, `false`
2163 #### `true` (default):
2177 ## `type_punctuation_density`
2179 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2181 - **Default value**: `"Wide"`
2182 - **Possible values**: `"Compressed"`, `"Wide"`
2184 #### `"Wide"` (default):
2187 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2192 #### `"Compressed"`:
2195 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2200 ## `use_try_shorthand`
2202 Replace uses of the try! macro by the ? shorthand
2204 - **Default value**: `false`
2205 - **Possible values**: `true`, `false`
2207 #### `false` (default):
2210 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2216 let lorem = ipsum.map(|dolor| dolor.sit())?;
2221 Density of a where clause.
2223 - **Default value**: `"Vertical"`
2224 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2226 #### `"Vertical"` (default):
2230 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2233 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2241 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2243 #### `"CompressedIfEmpty"`:
2247 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2250 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2259 #### `"Compressed"`:
2263 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2266 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2277 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2281 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2290 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2292 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2296 Element layout inside a where clause
2298 - **Default value**: `"Vertical"`
2299 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2301 #### `"Vertical"` (default):
2304 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2305 where Ipsum: IpsumDolorSitAmet,
2306 Dolor: DolorSitAmetConsectetur
2311 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2312 where Ipsum: IpsumDolorSitAmet,
2313 Dolor: DolorSitAmetConsectetur,
2314 Sit: SitAmetConsecteturAdipiscing,
2315 Amet: AmetConsecteturAdipiscingElit
2321 #### `"Horizontal"`:
2324 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2325 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2330 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2331 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2337 #### `"HorizontalVertical"`:
2340 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2341 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2346 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2347 where Ipsum: IpsumDolorSitAmet,
2348 Dolor: DolorSitAmetConsectetur,
2349 Sit: SitAmetConsecteturAdipiscing,
2350 Amet: AmetConsecteturAdipiscingElit
2359 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2360 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2365 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2366 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2367 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2373 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2375 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2377 ## `where_pred_indent`
2379 Indentation style of a where predicate
2381 - **Default value**: `"Visual"`
2382 - **Possible values**: `"Block"`, `"Visual"`
2384 #### `"Visual"` (default):
2387 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2400 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2410 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2412 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2416 Overall strategy for where clauses
2418 - **Default value**: `"Rfc"`
2419 - **Possible values**: `"Rfc"`, `"Legacy"`
2421 #### `"Rfc"` (default):
2424 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2438 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2448 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2452 Break comments to fit on the line
2454 - **Default value**: `false`
2455 - **Possible values**: `true`, `false`
2457 #### `false` (default):
2460 // 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.
2466 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2467 // sed do eiusmod tempor incididunt ut labore et dolore
2468 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2469 // exercitation ullamco laboris nisi ut aliquip ex ea
2470 // commodo consequat.
2473 ## `wrap_match_arms`
2475 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2477 - **Default value**: `true`
2478 - **Possible values**: `true`, `false`
2480 #### `true` (default):
2485 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2487 false => println!("{}", sit),
2496 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2497 false => println!("{}", sit),
2501 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2505 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2507 - **Default value**: `"Overwrite"`
2508 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`