3 Rustfmt is designed to be very configurable. You can create a TOML file called `rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent directory and it will apply the options in that file.
5 A possible content of `rustfmt.toml` or `.rustfmt.toml` might look like this:
10 reorder_imported_names = true
13 # Configuration Options
15 Below you find a detailed visual guide on all the supported configuration options of rustfmt:
17 ## `array_horizontal_layout_threshold`
19 How many elements array must have before rustfmt uses horizontal layout.
20 Use this option to prevent a huge array from being vertically formatted.
22 - **Default value**: `0`
23 - **Possible values**: any positive integer
25 **Note:** A value of `0` results in [`indent_style`](#indent_style) being applied regardless of a line's width.
30 // Each element will be placed on its own line.
46 // Each element will be placed on the same line as much as possible.
55 Indent on expressions or items.
57 - **Default value**: `"Block"`
58 - **Possible values**: `"Block"`, `"Visual"`
62 #### `"Block"` (default):
79 let lorem = vec!["ipsum",
90 #### `"Block"` (default):
111 See also: [`control_brace_style`](#control_brace_style).
113 ### Function arguments
115 #### `"Block"` (default):
120 fn lorem(ipsum: usize) {}
140 fn lorem(ipsum: usize) {}
142 fn lorem(ipsum: usize,
155 #### `"Block"` (default):
185 #### `"Block"` (default):
193 Adipiscing: Eq = usize,
194 Consectetur: Eq = usize,
201 adipiscing: Adipiscing,
202 consectetur: Consectetur,
212 fn lorem<Ipsum: Eq = usize,
216 Adipiscing: Eq = usize,
217 Consectetur: Eq = usize,
223 adipiscing: Adipiscing,
224 consectetur: Consectetur,
233 #### `"Block"` (default):
245 let lorem = Lorem { ipsum: dolor,
249 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
253 #### `"Block"` (default):
256 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
270 fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
280 See also: [`where_density`](#where_density), [`where_layout`](#where_layout).
284 Maximum width of an array literal before falling back to vertical formatting
286 - **Default value**: `60`
287 - **Possible values**: any positive integer
289 **Note:** A value of `0` results in [`indent_style`](#indent_style) being applied regardless of a line's width.
291 #### Lines shorter than `array_width`:
293 let lorem = vec!["ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit"];
296 #### Lines longer than `array_width`:
297 See [`indent_style`](#indent_style).
299 ## `attributes_on_same_line_as_field`
301 Try to put attributes on the same line as fields
303 - **Default value**: `true`
304 - **Possible values**: `true`, `false`
306 #### `true` (default):
310 #[serde(rename = "Ipsum")] ipsum: usize,
311 #[serde(rename = "Dolor")] dolor: usize,
312 #[serde(rename = "Amet")] amet: usize,
320 #[serde(rename = "Ipsum")]
322 #[serde(rename = "Dolor")]
324 #[serde(rename = "Amet")]
329 ## `attributes_on_same_line_as_variant`
331 Try to put attributes on the same line as variants
333 - **Default value**: `true`
334 - **Possible values**: `true`, `false`
336 #### `true` (default):
340 #[serde(skip_serializing)] Ipsum,
341 #[serde(skip_serializing)] Dolor,
342 #[serde(skip_serializing)] Amet,
350 #[serde(skip_serializing)]
352 #[serde(skip_serializing)]
354 #[serde(skip_serializing)]
361 Where to put a binary operator when a binary expression goes multiline.
363 - **Default value**: `"Front"`
364 - **Possible values**: `"Front"`, `"Back"`
366 #### `"Front"` (default):
377 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
378 ..bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
392 let range = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..
393 bbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
400 - **Default value**: `"Block"`
401 - **Possible values**: `"Block"`, `"Visual"`
403 #### `"Block"` (default):
418 let lorem = ipsum.dolor()
426 See also [`chain_width`](#chain_width).
430 Maximum length of a chain to fit on a single line
432 - **Default value**: `60`
433 - **Possible values**: any positive integer
435 #### Lines shorter than `chain_width`:
437 let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elit();
440 #### Lines longer than `chain_width`:
441 See [`chain_indent`](#chain_indent).
443 ## `chain_split_single_child`
445 Split a chain with a single child if its length exceeds [`chain_width`](#chain_width).
447 - **Default value**: `false`
448 - **Possible values**: `false`, `true`
450 #### `false` (default):
453 let files = fs::read_dir("tests/coverage/source").expect("Couldn't read source dir");
459 let files = fs::read_dir("tests/coverage/source")
460 .expect("Couldn't read source dir");
463 See also [`chain_width`](#chain_width).
465 ## `combine_control_expr`
467 Combine control expressions with function calls.
469 - **Default value**: `true`
470 - **Possible values**: `true`, `false`
472 #### `true` (default):
484 foo!(if let Some(..) = x {
497 foo!(while let Some(..) = x {
531 if let Some(..) = x {
548 while let Some(..) = x {
574 Maximum length of comments. No effect unless`wrap_comments = true`.
576 - **Default value**: `80`
577 - **Possible values**: any positive integer
579 **Note:** A value of `0` results in [`wrap_comments`](#wrap_comments) being applied regardless of a line's width.
581 #### Comments shorter than `comment_width`:
583 // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
586 #### Comments longer than `comment_width`:
588 // Lorem ipsum dolor sit amet,
589 // consectetur adipiscing elit.
592 See also [`wrap_comments`](#wrap_comments).
594 ## `condense_wildcard_suffixes`
596 Replace strings of _ wildcards by a single .. in tuple patterns
598 - **Default value**: `false`
599 - **Possible values**: `true`, `false`
601 #### `false` (default):
604 let (lorem, ipsum, _, _) = (1, 2, 3, 4);
610 let (lorem, ipsum, ..) = (1, 2, 3, 4);
613 ## `control_brace_style`
615 Brace style for control flow constructs
617 - **Default value**: `"AlwaysSameLine"`
618 - **Possible values**: `"AlwaysNextLine"`, `"AlwaysSameLine"`, `"ClosingNextLine"`
620 #### `"AlwaysSameLine"` (default):
630 #### `"AlwaysNextLine"`:
643 #### `"ClosingNextLine"`:
654 ## `disable_all_formatting`
656 Don't reformat anything
658 - **Default value**: `false`
659 - **Possible values**: `true`, `false`
661 ## `error_on_line_overflow`
663 Error if unable to get all lines within `max_width`
665 - **Default value**: `true`
666 - **Possible values**: `true`, `false`
668 See also [`max_width`](#max_width).
670 ## `error_on_line_overflow_comments`
672 Error if unable to get all comment lines within `comment_width`.
674 - **Default value**: `true`
675 - **Possible values**: `true`, `false`
677 See also [`comment_width`](#comment_width).
681 Argument density in functions
683 - **Default value**: `"Tall"`
684 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
686 #### `"Tall"` (default):
690 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
692 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
701 consectetur: Consectetur,
702 adipiscing: Adipiscing,
711 consectetur: Consectetur,
712 adipiscing: Adipiscing,
724 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
726 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
731 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
732 adipiscing: Adipiscing, elit: Elit,
736 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
737 adipiscing: Adipiscing, elit: Elit,
744 #### `"CompressedIfEmpty"`:
748 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
750 fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
755 ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: Consectetur,
756 adipiscing: Adipiscing, elit: Elit,
764 consectetur: Consectetur,
765 adipiscing: Adipiscing,
777 fn lorem(ipsum: Ipsum,
782 fn lorem(ipsum: Ipsum,
789 fn lorem(ipsum: Ipsum,
793 consectetur: Consectetur,
794 adipiscing: Adipiscing,
797 fn lorem(ipsum: Ipsum,
801 consectetur: Consectetur,
802 adipiscing: Adipiscing,
809 ## `fn_args_paren_newline`
811 If function argument parenthesis goes on a newline
813 - **Default value**: `false`
814 - **Possible values**: `true`, `false`
816 #### `false` (default):
824 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
838 ) -> DolorSitAmetConsecteturAdipiscingElitLoremIpsumDolorSitAmetConsecteturAdipiscingElit {
845 Brace style for items
847 - **Default value**: `"SameLineWhere"`
848 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
852 #### `"SameLineWhere"` (default):
859 fn lorem(ipsum: usize) {
863 fn lorem<T>(ipsum: T)
865 T: Add + Sub + Mul + Div,
871 #### `"AlwaysNextLine"`:
879 fn lorem(ipsum: usize)
884 fn lorem<T>(ipsum: T)
886 T: Add + Sub + Mul + Div,
892 #### `"PreferSameLine"`:
899 fn lorem(ipsum: usize) {
903 fn lorem<T>(ipsum: T)
905 T: Add + Sub + Mul + Div, {
910 ### Structs and enums
912 #### `"SameLineWhere"` (default):
926 #### `"AlwaysNextLine"`:
941 #### `"PreferSameLine"`:
956 Maximum width of the args of a function call before falling back to vertical formatting
958 - **Default value**: `60`
959 - **Possible values**: any positive integer
961 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
963 #### Function call shorter than `fn_call_width`:
965 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
968 #### Function call longer than `fn_call_width`:
970 See [`indent_style`](#indent_style).
972 ## `fn_empty_single_line`
974 Put empty-body functions on a single line
976 - **Default value**: `true`
977 - **Possible values**: `true`, `false`
979 #### `true` (default):
992 See also [`control_brace_style`](#control_brace_style).
994 ## `fn_return_indent`
996 Location of return type in function declaration
998 - **Default value**: `"WithArgs"`
999 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
1001 #### `"WithArgs"` (default):
1004 fn lorem(ipsum: Ipsum,
1008 consectetur: Consectetur,
1009 adipiscing: Adipiscing)
1018 #### `"WithWhereClause"`:
1021 fn lorem(ipsum: Ipsum,
1025 consectetur: Consectetur,
1026 adipiscing: Adipiscing)
1035 **Note**: This option only takes effect when `indent_style` is set to `"Visual"`.
1039 Put single-expression functions on a single line
1041 - **Default value**: `false`
1042 - **Possible values**: `true`, `false`
1044 #### `false` (default):
1047 fn lorem() -> usize {
1051 fn lorem() -> usize {
1060 fn lorem() -> usize { 42 }
1062 fn lorem() -> usize {
1068 See also [`control_brace_style`](#control_brace_style).
1070 ## `force_explicit_abi`
1072 Always print the abi for extern items
1074 - **Default value**: `true`
1075 - **Possible values**: `true`, `false`
1077 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
1079 #### `true` (default):
1083 pub static lorem: c_int;
1091 pub static lorem: c_int;
1095 ## `force_format_strings`
1097 Always format string literals
1099 - **Default value**: `false`
1100 - **Possible values**: `true`, `false`
1102 See [`format_strings`](#format_strings).
1104 See also [`max_width`](#max_width).
1108 Format string literals where necessary
1110 - **Default value**: `false`
1111 - **Possible values**: `true`, `false`
1113 #### `false` (default):
1116 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
1123 "ipsum dolor sit amet consectetur \
1124 adipiscing elit lorem ipsum dolor sit";
1127 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
1131 Use tab characters for indentation, spaces for alignment
1133 - **Default value**: `false`
1134 - **Possible values**: `true`, `false`
1136 #### `false` (default):
1139 fn lorem() -> usize {
1140 42 // spaces before 42
1147 fn lorem() -> usize {
1148 42 // tabs before 42
1152 See also: [`tab_spaces`](#tab_spaces).
1154 ## `impl_empty_single_line`
1156 Put empty-body implementations on a single line
1158 - **Default value**: `true`
1159 - **Possible values**: `true`, `false`
1161 #### `true` (default):
1174 See also [`brace_style`](#brace_style).
1176 ## `indent_match_arms`
1178 Indent match arms instead of keeping them at the same indentation level as the match keyword
1180 - **Default value**: `true`
1181 - **Possible values**: `true`, `false`
1183 #### `true` (default):
1205 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1209 Indent style of imports
1211 - **Default Value**: `"Visual"`
1212 - **Possible values**: `"Block"`, `"Visual"`
1214 #### `"Visual"` (default):
1232 See also: [`imports_layout`](#imports_layout).
1236 Item layout inside a imports block
1238 - **Default value**: "Mixed"
1239 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1241 #### `"Mixed"` (default):
1244 use foo::{xxx, yyy, zzz};
1246 use foo::{aaa, bbb, ccc,
1250 #### `"Horizontal"`:
1252 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1255 use foo::{xxx, yyy, zzz};
1257 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1260 #### `"HorizontalVertical"`:
1263 use foo::{xxx, yyy, zzz};
1288 ## `match_arm_forces_newline`
1290 Consistently put match arms (block based or not) in a newline.
1292 - **Default value**: `false`
1293 - **Possible values**: `true`, `false`
1295 #### `false` (default):
1299 // a non-empty block
1306 X2 => println!("ok"),
1314 // a non-empty block
1328 See also: [`wrap_match_arms`](#wrap_match_arms).
1330 ## `match_block_trailing_comma`
1332 Put a trailing comma after a block based match arm (non-block arms are not affected)
1334 - **Default value**: `false`
1335 - **Possible values**: `true`, `false`
1337 #### `false` (default):
1344 Lorem::Dolor => println!("dolor"),
1355 Lorem::Dolor => println!("dolor"),
1359 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1361 ## `match_pattern_separator_break_point`
1363 Put a match sub-patterns' separator (`|`) in front or back.
1365 - **Default value**: `"Back"`
1366 - **Possible values**: `"Back"`, `"Front"`
1368 #### `"Back"` (default):
1390 | Variant::Tag6 => {}
1396 Maximum width of each line
1398 - **Default value**: `100`
1399 - **Possible values**: any positive integer
1401 See also [`error_on_line_overflow`](#error_on_line_overflow).
1405 Merge multiple derives into a single one.
1407 - **Default value**: `true`
1408 - **Possible values**: `true`, `false`
1410 #### `true` (default):
1413 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1420 #[derive(Eq, PartialEq)]
1422 #[derive(Copy, Clone)]
1426 ## `multiline_closure_forces_block`
1428 Force multiline closure bodies to be wrapped in a block
1430 - **Default value**: `false`
1431 - **Possible values**: `false`, `true`
1433 #### `false` (default):
1436 result.and_then(|maybe_value| match maybe_value {
1446 result.and_then(|maybe_value| {
1454 ## `multiline_match_arm_forces_block`
1456 Force multiline match arm bodies to be wrapped in a block
1458 - **Default value**: `false`
1459 - **Possible values**: `false`, `true`
1461 #### `false` (default):
1466 println!("Hello World");
1478 println!("Hello World");
1487 Unix or Windows line endings
1489 - **Default value**: `"Unix"`
1490 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1492 ## `normalize_comments`
1494 Convert /* */ comments to // comments where possible
1496 - **Default value**: `false`
1497 - **Possible values**: `true`, `false`
1499 #### `false` (default):
1503 fn dolor() -> usize {}
1506 fn adipiscing() -> usize {}
1513 fn dolor() -> usize {}
1516 fn adipiscing() -> usize {}
1519 ## `reorder_imported_names`
1521 Reorder lists of names in import statements alphabetically
1523 - **Default value**: `false`
1524 - **Possible values**: `true`, `false`
1526 #### `false` (default):
1529 use super::{lorem, ipsum, dolor, sit};
1535 use super::{dolor, ipsum, lorem, sit};
1538 See also [`reorder_imports`](#reorder_imports).
1540 ## `reorder_imports`
1542 Reorder import statements alphabetically
1544 - **Default value**: `false`
1545 - **Possible values**: `true`, `false`
1547 #### `false` (default):
1565 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1567 ## `reorder_imports_in_group`
1569 Reorder import statements in group
1571 - **Default value**: `false`
1572 - **Possible values**: `true`, `false`
1574 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1576 #### `false` (default):
1600 See also [`reorder_imports`](#reorder_imports).
1602 ## `reorder_extern_crates`
1604 Reorder `extern crate` statements alphabetically
1606 - **Default value**: `true`
1607 - **Possible values**: `true`, `false`
1609 #### `true` (default):
1627 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1629 ## `reorder_extern_crates_in_group`
1631 Reorder `extern crate` statements in group
1633 - **Default value**: `true`
1634 - **Possible values**: `true`, `false`
1636 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1638 #### `true` (default):
1662 See also [`reorder_extern_crates`](#reorder_extern_crates).
1666 Report `TODO` items in comments.
1668 - **Default value**: `"Never"`
1669 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1671 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1672 it contains a `#X` (with `X` being a number) in parentheses following the
1673 `TODO`, `"Unnumbered"` will ignore it.
1675 See also [`report_fixme`](#report_fixme).
1679 Report `FIXME` items in comments.
1681 - **Default value**: `"Never"`
1682 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1684 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1685 it contains a `#X` (with `X` being a number) in parentheses following the
1686 `FIXME`, `"Unnumbered"` will ignore it.
1688 See also [`report_todo`](#report_todo).
1690 ## `single_line_if_else_max_width`
1692 Maximum line length for single line if-else expressions.
1694 - **Default value**: `50`
1695 - **Possible values**: any positive integer
1697 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1699 #### Lines shorter than `single_line_if_else_max_width`:
1701 let lorem = if ipsum { dolor } else { sit };
1704 #### Lines longer than `single_line_if_else_max_width`:
1706 let lorem = if ipsum {
1713 See also: [`control_brace_style`](#control_brace_style).
1717 Don't reformat out of line modules
1719 - **Default value**: `false`
1720 - **Possible values**: `true`, `false`
1722 ## `space_after_bound_colon`
1724 Leave a space after the colon in a trait or lifetime bound
1726 - **Default value**: `true`
1727 - **Possible values**: `true`, `false`
1729 #### `true` (default):
1732 fn lorem<T: Eq>(t: T) {
1740 fn lorem<T:Eq>(t: T) {
1745 See also: [`space_before_bound`](#space_before_bound).
1747 ## `struct_field_align_threshold`
1749 The maximum diff of width between struct fields to be aligned with each other.
1751 - **Default value** : 0
1752 - **Possible values**: any positive integer
1774 ## `space_after_struct_lit_field_colon`
1776 Leave a space after the colon in a struct literal field
1778 - **Default value**: `true`
1779 - **Possible values**: `true`, `false`
1781 #### `true` (default):
1799 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1801 ## `space_after_type_annotation_colon`
1803 Leave a space after the colon in a type annotation
1805 - **Default value**: `true`
1806 - **Possible values**: `true`, `false`
1808 #### `true` (default):
1811 fn lorem<T: Eq>(t: T) {
1812 let ipsum: Dolor = sit;
1819 fn lorem<T: Eq>(t:T) {
1820 let ipsum:Dolor = sit;
1824 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1826 ## `space_before_bound`
1828 Leave a space before the colon in a trait or lifetime bound
1830 - **Default value**: `false`
1831 - **Possible values**: `true`, `false`
1833 #### `false` (default):
1836 fn lorem<T: Eq>(t: T) {
1837 let ipsum: Dolor = sit;
1844 fn lorem<T : Eq>(t: T) {
1845 let ipsum: Dolor = sit;
1849 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1851 ## `space_before_struct_lit_field_colon`
1853 Leave a space before the colon in a struct literal field
1855 - **Default value**: `false`
1856 - **Possible values**: `true`, `false`
1858 #### `false` (default):
1876 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1878 ## `space_before_type_annotation`
1880 Leave a space before the colon in a type annotation
1882 - **Default value**: `false`
1883 - **Possible values**: `true`, `false`
1885 #### `false` (default):
1888 fn lorem<T: Eq>(t: T) {
1889 let ipsum: Dolor = sit;
1896 fn lorem<T: Eq>(t : T) {
1897 let ipsum : Dolor = sit;
1901 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1903 ## `spaces_around_ranges`
1905 Put spaces around the .. and ... range operators
1907 - **Default value**: `false`
1908 - **Possible values**: `true`, `false`
1910 #### `false` (default):
1919 let lorem = 0 .. 10;
1922 ## `spaces_within_angle_brackets`
1924 Put spaces within non-empty generic arguments
1926 - **Default value**: `false`
1927 - **Possible values**: `true`, `false`
1929 #### `false` (default):
1932 fn lorem<T: Eq>(t: T) {
1940 fn lorem< T: Eq >(t: T) {
1945 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1947 ## `spaces_within_parens`
1949 Put spaces within non-empty parentheses
1951 - **Default value**: `false`
1952 - **Possible values**: `true`, `false`
1954 #### `false` (default):
1957 fn lorem<T: Eq>(t: T) {
1958 let lorem = (ipsum, dolor);
1965 fn lorem<T: Eq>( t: T ) {
1966 let lorem = ( ipsum, dolor );
1970 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1972 ## `spaces_within_square_brackets`
1974 Put spaces within non-empty square brackets
1976 - **Default value**: `false`
1977 - **Possible values**: `true`, `false`
1979 #### `false` (default):
1982 let lorem: [usize; 2] = [ipsum, dolor];
1988 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1991 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1993 ## `struct_lit_multiline_style`
1995 Multiline style on literal structs
1997 - **Default value**: `"PreferSingle"`
1998 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
2000 #### `"PreferSingle"` (default):
2003 let lorem = Lorem { ipsum: dolor, sit: amet };
2006 #### `"ForceMulti"`:
2015 See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
2017 ## `struct_lit_width`
2019 Maximum width in the body of a struct lit before falling back to vertical formatting
2021 - **Default value**: `18`
2022 - **Possible values**: any positive integer
2024 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2026 #### Lines shorter than `struct_lit_width`:
2028 let lorem = Lorem { ipsum: dolor, sit: amet };
2031 #### Lines longer than `struct_lit_width`:
2032 See [`indent_style`](#indent_style).
2034 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
2036 ## `struct_variant_width`
2038 Maximum width in the body of a struct variant before falling back to vertical formatting
2040 - **Default value**: `35`
2041 - **Possible values**: any positive integer
2043 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2045 #### Struct variants shorter than `struct_variant_width`:
2050 Sit { amet: Consectetur, adipiscing: Elit },
2054 #### Struct variants longer than `struct_variant_width`:
2068 Number of spaces per tab
2070 - **Default value**: `4`
2071 - **Possible values**: any positive integer
2077 let ipsum = dolor();
2079 "amet consectetur adipiscing elit."
2088 let ipsum = dolor();
2090 "amet consectetur adipiscing elit."
2095 See also: [`hard_tabs`](#hard_tabs).
2097 ## `take_source_hints`
2099 Retain some formatting characteristics from the source code
2101 - **Default value**: `false`
2102 - **Possible values**: `true`, `false`
2104 #### `false` (default):
2109 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2125 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2129 How to handle trailing commas for lists
2131 - **Default value**: `"Vertical"`
2132 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2134 #### `"Vertical"` (default):
2137 let Lorem { ipsum, dolor, sit } = amet;
2151 let Lorem { ipsum, dolor, sit, } = amet;
2165 let Lorem { ipsum, dolor, sit } = amet;
2176 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2178 ## `trailing_semicolon`
2180 Add trailing semicolon after break, continue and return
2182 - **Default value**: `true`
2183 - **Possible values**: `true`, `false`
2185 #### `true` (default):
2199 ## `type_punctuation_density`
2201 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2203 - **Default value**: `"Wide"`
2204 - **Possible values**: `"Compressed"`, `"Wide"`
2206 #### `"Wide"` (default):
2209 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2214 #### `"Compressed"`:
2217 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2222 ## `use_try_shorthand`
2224 Replace uses of the try! macro by the ? shorthand
2226 - **Default value**: `false`
2227 - **Possible values**: `true`, `false`
2229 #### `false` (default):
2232 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2238 let lorem = ipsum.map(|dolor| dolor.sit())?;
2243 Density of a where clause.
2245 - **Default value**: `"Vertical"`
2246 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2248 #### `"Vertical"` (default):
2252 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2256 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2265 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2267 #### `"CompressedIfEmpty"`:
2271 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2274 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2283 #### `"Compressed"`:
2287 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2290 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2301 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2305 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2314 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2316 See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
2320 Element layout inside a where clause
2322 - **Default value**: `"Vertical"`
2323 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2325 #### `"Vertical"` (default):
2328 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2329 where Ipsum: IpsumDolorSitAmet,
2330 Dolor: DolorSitAmetConsectetur
2335 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2336 where Ipsum: IpsumDolorSitAmet,
2337 Dolor: DolorSitAmetConsectetur,
2338 Sit: SitAmetConsecteturAdipiscing,
2339 Amet: AmetConsecteturAdipiscingElit
2345 #### `"Horizontal"`:
2348 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2349 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2354 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2355 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2361 #### `"HorizontalVertical"`:
2364 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2365 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2370 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2371 where Ipsum: IpsumDolorSitAmet,
2372 Dolor: DolorSitAmetConsectetur,
2373 Sit: SitAmetConsecteturAdipiscing,
2374 Amet: AmetConsecteturAdipiscingElit
2383 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2384 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2389 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2390 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2391 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2397 See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
2401 Break comments to fit on the line
2403 - **Default value**: `false`
2404 - **Possible values**: `true`, `false`
2406 #### `false` (default):
2409 // 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.
2415 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2416 // sed do eiusmod tempor incididunt ut labore et dolore
2417 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2418 // exercitation ullamco laboris nisi ut aliquip ex ea
2419 // commodo consequat.
2422 ## `wrap_match_arms`
2424 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2426 - **Default value**: `true`
2427 - **Possible values**: `true`, `false`
2429 #### `true` (default):
2434 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2436 false => println!("{}", sit),
2445 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2446 false => println!("{}", sit),
2450 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2454 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2456 - **Default value**: `"Overwrite"`
2457 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`