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).
1617 ## `single_line_if_else_max_width`
1619 Maximum line length for single line if-else expressions.
1621 - **Default value**: `50`
1622 - **Possible values**: any positive integer
1624 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1626 #### Lines shorter than `single_line_if_else_max_width`:
1628 let lorem = if ipsum { dolor } else { sit };
1631 #### Lines longer than `single_line_if_else_max_width`:
1633 let lorem = if ipsum {
1640 See also: [`control_brace_style`](#control_brace_style).
1644 Don't reformat out of line modules
1646 - **Default value**: `false`
1647 - **Possible values**: `true`, `false`
1649 ## `space_after_bound_colon`
1651 Leave a space after the colon in a trait or lifetime bound
1653 - **Default value**: `true`
1654 - **Possible values**: `true`, `false`
1656 #### `true` (default):
1659 fn lorem<T: Eq>(t: T) {
1667 fn lorem<T:Eq>(t: T) {
1672 See also: [`space_before_bound`](#space_before_bound).
1674 ## `struct_field_align_threshold`
1676 The maximum diff of width between struct fields to be aligned with each other.
1678 - **Default value** : 0
1679 - **Possible values**: any positive integer
1701 ## `space_after_struct_lit_field_colon`
1703 Leave a space after the colon in a struct literal field
1705 - **Default value**: `true`
1706 - **Possible values**: `true`, `false`
1708 #### `true` (default):
1726 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1728 ## `space_after_type_annotation_colon`
1730 Leave a space after the colon in a type annotation
1732 - **Default value**: `true`
1733 - **Possible values**: `true`, `false`
1735 #### `true` (default):
1738 fn lorem<T: Eq>(t: T) {
1739 let ipsum: Dolor = sit;
1746 fn lorem<T: Eq>(t:T) {
1747 let ipsum:Dolor = sit;
1751 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1753 ## `space_before_bound`
1755 Leave a space before the colon in a trait or lifetime bound
1757 - **Default value**: `false`
1758 - **Possible values**: `true`, `false`
1760 #### `false` (default):
1763 fn lorem<T: Eq>(t: T) {
1764 let ipsum: Dolor = sit;
1771 fn lorem<T : Eq>(t: T) {
1772 let ipsum: Dolor = sit;
1776 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1778 ## `space_before_struct_lit_field_colon`
1780 Leave a space before the colon in a struct literal field
1782 - **Default value**: `false`
1783 - **Possible values**: `true`, `false`
1785 #### `false` (default):
1803 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1805 ## `space_before_type_annotation`
1807 Leave a space before the colon in a type annotation
1809 - **Default value**: `false`
1810 - **Possible values**: `true`, `false`
1812 #### `false` (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_after_type_annotation_colon`](#space_after_type_annotation_colon).
1830 ## `spaces_around_ranges`
1832 Put spaces around the .. and ... range operators
1834 - **Default value**: `false`
1835 - **Possible values**: `true`, `false`
1837 #### `false` (default):
1846 let lorem = 0 .. 10;
1849 ## `spaces_within_angle_brackets`
1851 Put spaces within non-empty generic arguments
1853 - **Default value**: `false`
1854 - **Possible values**: `true`, `false`
1856 #### `false` (default):
1859 fn lorem<T: Eq>(t: T) {
1867 fn lorem< T: Eq >(t: T) {
1872 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1874 ## `spaces_within_parens`
1876 Put spaces within non-empty parentheses
1878 - **Default value**: `false`
1879 - **Possible values**: `true`, `false`
1881 #### `false` (default):
1884 fn lorem<T: Eq>(t: T) {
1885 let lorem = (ipsum, dolor);
1892 fn lorem<T: Eq>( t: T ) {
1893 let lorem = ( ipsum, dolor );
1897 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1899 ## `spaces_within_square_brackets`
1901 Put spaces within non-empty square brackets
1903 - **Default value**: `false`
1904 - **Possible values**: `true`, `false`
1906 #### `false` (default):
1909 let lorem: [usize; 2] = [ipsum, dolor];
1915 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1918 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1920 ## `struct_lit_multiline_style`
1922 Multiline style on literal structs
1924 - **Default value**: `"PreferSingle"`
1925 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
1927 #### `"PreferSingle"` (default):
1930 let lorem = Lorem { ipsum: dolor, sit: amet };
1933 #### `"ForceMulti"`:
1942 See also: [`struct_lit_indent`](#struct_lit_indent), [`struct_lit_width`](#struct_lit_width).
1944 ## `struct_lit_indent`
1946 Style of struct definition
1948 - **Default value**: `"Block"`
1949 - **Possible values**: `"Block"`, `"Visual"`
1951 #### `"Block"` (default):
1963 let lorem = Lorem { ipsum: dolor,
1967 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
1969 ## `struct_lit_width`
1971 Maximum width in the body of a struct lit before falling back to vertical formatting
1973 - **Default value**: `18`
1974 - **Possible values**: any positive integer
1976 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1978 #### Lines shorter than `struct_lit_width`:
1980 let lorem = Lorem { ipsum: dolor, sit: amet };
1983 #### Lines longer than `struct_lit_width`:
1984 See [`struct_lit_indent`](#struct_lit_indent).
1986 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`struct_lit_indent`](#struct_lit_indent).
1988 ## `struct_variant_width`
1990 Maximum width in the body of a struct variant before falling back to vertical formatting
1992 - **Default value**: `35`
1993 - **Possible values**: any positive integer
1995 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
1997 #### Struct variants shorter than `struct_variant_width`:
2002 Sit { amet: Consectetur, adipiscing: Elit },
2006 #### Struct variants longer than `struct_variant_width`:
2020 Number of spaces per tab
2022 - **Default value**: `4`
2023 - **Possible values**: any positive integer
2029 let ipsum = dolor();
2031 "amet consectetur adipiscing elit."
2040 let ipsum = dolor();
2042 "amet consectetur adipiscing elit."
2047 See also: [`hard_tabs`](#hard_tabs).
2049 ## `take_source_hints`
2051 Retain some formatting characteristics from the source code
2053 - **Default value**: `false`
2054 - **Possible values**: `true`, `false`
2056 #### `false` (default):
2061 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2077 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2081 How to handle trailing commas for lists
2083 - **Default value**: `"Vertical"`
2084 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2086 #### `"Vertical"` (default):
2089 let Lorem { ipsum, dolor, sit } = amet;
2103 let Lorem { ipsum, dolor, sit, } = amet;
2117 let Lorem { ipsum, dolor, sit } = amet;
2128 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2130 ## `trailing_semicolon`
2132 Add trailing semicolon after break, continue and return
2134 - **Default value**: `true`
2135 - **Possible values**: `true`, `false`
2137 #### `true` (default):
2151 ## `type_punctuation_density`
2153 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2155 - **Default value**: `"Wide"`
2156 - **Possible values**: `"Compressed"`, `"Wide"`
2158 #### `"Wide"` (default):
2161 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2166 #### `"Compressed"`:
2169 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2174 ## `use_try_shorthand`
2176 Replace uses of the try! macro by the ? shorthand
2178 - **Default value**: `false`
2179 - **Possible values**: `true`, `false`
2181 #### `false` (default):
2184 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2190 let lorem = ipsum.map(|dolor| dolor.sit())?;
2195 Density of a where clause.
2197 - **Default value**: `"Vertical"`
2198 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2200 #### `"Vertical"` (default):
2204 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2207 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2215 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2217 #### `"CompressedIfEmpty"`:
2221 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2224 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2233 #### `"Compressed"`:
2237 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2240 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2251 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2255 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2264 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2266 See also: [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2270 Element layout inside a where clause
2272 - **Default value**: `"Vertical"`
2273 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2275 #### `"Vertical"` (default):
2278 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2279 where Ipsum: IpsumDolorSitAmet,
2280 Dolor: DolorSitAmetConsectetur
2285 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2286 where Ipsum: IpsumDolorSitAmet,
2287 Dolor: DolorSitAmetConsectetur,
2288 Sit: SitAmetConsecteturAdipiscing,
2289 Amet: AmetConsecteturAdipiscingElit
2295 #### `"Horizontal"`:
2298 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2299 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2304 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2305 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2311 #### `"HorizontalVertical"`:
2314 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2315 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2320 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2321 where Ipsum: IpsumDolorSitAmet,
2322 Dolor: DolorSitAmetConsectetur,
2323 Sit: SitAmetConsecteturAdipiscing,
2324 Amet: AmetConsecteturAdipiscingElit
2333 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2334 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2339 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2340 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2341 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2347 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2349 See also: [`where_density`](#where_density), [`where_pred_indent`](#where_pred_indent), [`where_style`](#where_style).
2351 ## `where_pred_indent`
2353 Indentation style of a where predicate
2355 - **Default value**: `"Visual"`
2356 - **Possible values**: `"Block"`, `"Visual"`
2358 #### `"Visual"` (default):
2361 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2374 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2384 **Note**: This option only takes effect when `where_style` is set to `"Legacy"`.
2386 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_style`](#where_style).
2390 Overall strategy for where clauses
2392 - **Default value**: `"Rfc"`
2393 - **Possible values**: `"Rfc"`, `"Legacy"`
2395 #### `"Rfc"` (default):
2398 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2412 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
2422 See also: [`where_density`](#where_density), [`where_layout`](#where_layout), [`where_pred_indent`](#where_pred_indent).
2426 Break comments to fit on the line
2428 - **Default value**: `false`
2429 - **Possible values**: `true`, `false`
2431 #### `false` (default):
2434 // 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.
2440 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2441 // sed do eiusmod tempor incididunt ut labore et dolore
2442 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2443 // exercitation ullamco laboris nisi ut aliquip ex ea
2444 // commodo consequat.
2447 ## `wrap_match_arms`
2449 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2451 - **Default value**: `true`
2452 - **Possible values**: `true`, `false`
2454 #### `true` (default):
2459 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2461 false => println!("{}", sit),
2470 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2471 false => println!("{}", sit),
2475 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2479 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2481 - **Default value**: `"Overwrite"`
2482 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`