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 functions
847 - **Default value**: `"SameLineWhere"`
848 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
850 #### `"SameLineWhere"` (default):
857 fn lorem(ipsum: usize) {
861 fn lorem<T>(ipsum: T)
863 T: Add + Sub + Mul + Div,
869 #### `"AlwaysNextLine"`:
877 fn lorem(ipsum: usize)
882 fn lorem<T>(ipsum: T)
884 T: Add + Sub + Mul + Div,
890 #### `"PreferSameLine"`:
897 fn lorem(ipsum: usize) {
901 fn lorem<T>(ipsum: T)
903 T: Add + Sub + Mul + Div, {
910 Maximum width of the args of a function call before falling back to vertical formatting
912 - **Default value**: `60`
913 - **Possible values**: any positive integer
915 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
917 #### Function call shorter than `fn_call_width`:
919 lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
922 #### Function call longer than `fn_call_width`:
924 See [`indent_style`](#indent_style).
926 ## `fn_empty_single_line`
928 Put empty-body functions on a single line
930 - **Default value**: `true`
931 - **Possible values**: `true`, `false`
933 #### `true` (default):
946 See also [`control_brace_style`](#control_brace_style).
948 ## `fn_return_indent`
950 Location of return type in function declaration
952 - **Default value**: `"WithArgs"`
953 - **Possible values**: `"WithArgs"`, `"WithWhereClause"`
955 #### `"WithArgs"` (default):
958 fn lorem(ipsum: Ipsum,
962 consectetur: Consectetur,
963 adipiscing: Adipiscing)
972 #### `"WithWhereClause"`:
975 fn lorem(ipsum: Ipsum,
979 consectetur: Consectetur,
980 adipiscing: Adipiscing)
989 **Note**: This option only takes effect when `indent_style` is set to `"Visual"`.
993 Put single-expression functions on a single line
995 - **Default value**: `false`
996 - **Possible values**: `true`, `false`
998 #### `false` (default):
1001 fn lorem() -> usize {
1005 fn lorem() -> usize {
1014 fn lorem() -> usize { 42 }
1016 fn lorem() -> usize {
1022 See also [`control_brace_style`](#control_brace_style).
1024 ## `force_explicit_abi`
1026 Always print the abi for extern items
1028 - **Default value**: `true`
1029 - **Possible values**: `true`, `false`
1031 **Note:** Non-"C" ABIs are always printed. If `false` then "C" is removed.
1033 #### `true` (default):
1037 pub static lorem: c_int;
1045 pub static lorem: c_int;
1049 ## `force_format_strings`
1051 Always format string literals
1053 - **Default value**: `false`
1054 - **Possible values**: `true`, `false`
1056 See [`format_strings`](#format_strings).
1058 See also [`max_width`](#max_width).
1062 Format string literals where necessary
1064 - **Default value**: `false`
1065 - **Possible values**: `true`, `false`
1067 #### `false` (default):
1070 let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
1077 "ipsum dolor sit amet consectetur \
1078 adipiscing elit lorem ipsum dolor sit";
1081 See also [`force_format_strings`](#force_format_strings), [`max_width`](#max_width).
1085 Use tab characters for indentation, spaces for alignment
1087 - **Default value**: `false`
1088 - **Possible values**: `true`, `false`
1090 #### `false` (default):
1093 fn lorem() -> usize {
1094 42 // spaces before 42
1101 fn lorem() -> usize {
1102 42 // tabs before 42
1106 See also: [`tab_spaces`](#tab_spaces).
1108 ## `impl_empty_single_line`
1110 Put empty-body implementations on a single line
1112 - **Default value**: `true`
1113 - **Possible values**: `true`, `false`
1115 #### `true` (default):
1128 See also [`item_brace_style`](#item_brace_style).
1130 ## `indent_match_arms`
1132 Indent match arms instead of keeping them at the same indentation level as the match keyword
1134 - **Default value**: `true`
1135 - **Possible values**: `true`, `false`
1137 #### `true` (default):
1159 See also: [`match_block_trailing_comma`](#match_block_trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1163 Indent style of imports
1165 - **Default Value**: `"Visual"`
1166 - **Possible values**: `"Block"`, `"Visual"`
1168 #### `"Visual"` (default):
1186 See also: [`imports_layout`](#imports_layout).
1190 Item layout inside a imports block
1192 - **Default value**: "Mixed"
1193 - **Possible values**: "Horizontal", "HorizontalVertical", "Mixed", "Vertical"
1195 #### `"Mixed"` (default):
1198 use foo::{xxx, yyy, zzz};
1200 use foo::{aaa, bbb, ccc,
1204 #### `"Horizontal"`:
1206 **Note**: This option forces to put everything on one line and may exceeds `max_width`.
1209 use foo::{xxx, yyy, zzz};
1211 use foo::{aaa, bbb, ccc, ddd, eee, fff};
1214 #### `"HorizontalVertical"`:
1217 use foo::{xxx, yyy, zzz};
1242 ## `item_brace_style`
1244 Brace style for structs and enums
1246 - **Default value**: `"SameLineWhere"`
1247 - **Possible values**: `"AlwaysNextLine"`, `"PreferSameLine"`, `"SameLineWhere"`
1249 #### `"SameLineWhere"` (default):
1263 #### `"AlwaysNextLine"`:
1278 #### `"PreferSameLine"`:
1291 ## `match_arm_forces_newline`
1293 Consistently put match arms (block based or not) in a newline.
1295 - **Default value**: `false`
1296 - **Possible values**: `true`, `false`
1298 #### `false` (default):
1302 // a non-empty block
1309 X2 => println!("ok"),
1317 // a non-empty block
1331 See also: [`wrap_match_arms`](#wrap_match_arms).
1333 ## `match_block_trailing_comma`
1335 Put a trailing comma after a block based match arm (non-block arms are not affected)
1337 - **Default value**: `false`
1338 - **Possible values**: `true`, `false`
1340 #### `false` (default):
1347 Lorem::Dolor => println!("dolor"),
1358 Lorem::Dolor => println!("dolor"),
1362 See also: [`indent_match_arms`](#indent_match_arms), [`trailing_comma`](#trailing_comma), [`wrap_match_arms`](#wrap_match_arms).
1364 ## `match_pattern_separator_break_point`
1366 Put a match sub-patterns' separator (`|`) in front or back.
1368 - **Default value**: `"Back"`
1369 - **Possible values**: `"Back"`, `"Front"`
1371 #### `"Back"` (default):
1393 | Variant::Tag6 => {}
1399 Maximum width of each line
1401 - **Default value**: `100`
1402 - **Possible values**: any positive integer
1404 See also [`error_on_line_overflow`](#error_on_line_overflow).
1408 Merge multiple derives into a single one.
1410 - **Default value**: `true`
1411 - **Possible values**: `true`, `false`
1413 #### `true` (default):
1416 #[derive(Eq, PartialEq, Debug, Copy, Clone)]
1423 #[derive(Eq, PartialEq)]
1425 #[derive(Copy, Clone)]
1429 ## `multiline_closure_forces_block`
1431 Force multiline closure bodies to be wrapped in a block
1433 - **Default value**: `false`
1434 - **Possible values**: `false`, `true`
1436 #### `false` (default):
1439 result.and_then(|maybe_value| match maybe_value {
1449 result.and_then(|maybe_value| {
1457 ## `multiline_match_arm_forces_block`
1459 Force multiline match arm bodies to be wrapped in a block
1461 - **Default value**: `false`
1462 - **Possible values**: `false`, `true`
1464 #### `false` (default):
1469 println!("Hello World");
1481 println!("Hello World");
1490 Unix or Windows line endings
1492 - **Default value**: `"Unix"`
1493 - **Possible values**: `"Native"`, `"Unix"`, `"Windows"`
1495 ## `normalize_comments`
1497 Convert /* */ comments to // comments where possible
1499 - **Default value**: `false`
1500 - **Possible values**: `true`, `false`
1502 #### `false` (default):
1506 fn dolor() -> usize {}
1509 fn adipiscing() -> usize {}
1516 fn dolor() -> usize {}
1519 fn adipiscing() -> usize {}
1522 ## `reorder_imported_names`
1524 Reorder lists of names in import statements alphabetically
1526 - **Default value**: `false`
1527 - **Possible values**: `true`, `false`
1529 #### `false` (default):
1532 use super::{lorem, ipsum, dolor, sit};
1538 use super::{dolor, ipsum, lorem, sit};
1541 See also [`reorder_imports`](#reorder_imports).
1543 ## `reorder_imports`
1545 Reorder import statements alphabetically
1547 - **Default value**: `false`
1548 - **Possible values**: `true`, `false`
1550 #### `false` (default):
1568 See also [`reorder_imported_names`](#reorder_imported_names), [`reorder_imports_in_group`](#reorder_imports_in_group).
1570 ## `reorder_imports_in_group`
1572 Reorder import statements in group
1574 - **Default value**: `false`
1575 - **Possible values**: `true`, `false`
1577 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1579 #### `false` (default):
1603 See also [`reorder_imports`](#reorder_imports).
1605 ## `reorder_extern_crates`
1607 Reorder `extern crate` statements alphabetically
1609 - **Default value**: `true`
1610 - **Possible values**: `true`, `false`
1612 #### `true` (default):
1630 See also [`reorder_extern_crates_in_group`](#reorder_extern_crates_in_group).
1632 ## `reorder_extern_crates_in_group`
1634 Reorder `extern crate` statements in group
1636 - **Default value**: `true`
1637 - **Possible values**: `true`, `false`
1639 **Note:** This option takes effect only when [`reorder_imports`](#reorder_imports) is set to `true`.
1641 #### `true` (default):
1665 See also [`reorder_extern_crates`](#reorder_extern_crates).
1669 Report `TODO` items in comments.
1671 - **Default value**: `"Never"`
1672 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1674 Warns about any comments containing `TODO` in them when set to `"Always"`. If
1675 it contains a `#X` (with `X` being a number) in parentheses following the
1676 `TODO`, `"Unnumbered"` will ignore it.
1678 See also [`report_fixme`](#report_fixme).
1682 Report `FIXME` items in comments.
1684 - **Default value**: `"Never"`
1685 - **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
1687 Warns about any comments containing `FIXME` in them when set to `"Always"`. If
1688 it contains a `#X` (with `X` being a number) in parentheses following the
1689 `FIXME`, `"Unnumbered"` will ignore it.
1691 See also [`report_todo`](#report_todo).
1693 ## `single_line_if_else_max_width`
1695 Maximum line length for single line if-else expressions.
1697 - **Default value**: `50`
1698 - **Possible values**: any positive integer
1700 **Note:** A value of `0` results in if-else expressions being broken regardless of their line's width.
1702 #### Lines shorter than `single_line_if_else_max_width`:
1704 let lorem = if ipsum { dolor } else { sit };
1707 #### Lines longer than `single_line_if_else_max_width`:
1709 let lorem = if ipsum {
1716 See also: [`control_brace_style`](#control_brace_style).
1720 Don't reformat out of line modules
1722 - **Default value**: `false`
1723 - **Possible values**: `true`, `false`
1725 ## `space_after_bound_colon`
1727 Leave a space after the colon in a trait or lifetime bound
1729 - **Default value**: `true`
1730 - **Possible values**: `true`, `false`
1732 #### `true` (default):
1735 fn lorem<T: Eq>(t: T) {
1743 fn lorem<T:Eq>(t: T) {
1748 See also: [`space_before_bound`](#space_before_bound).
1750 ## `struct_field_align_threshold`
1752 The maximum diff of width between struct fields to be aligned with each other.
1754 - **Default value** : 0
1755 - **Possible values**: any positive integer
1777 ## `space_after_struct_lit_field_colon`
1779 Leave a space after the colon in a struct literal field
1781 - **Default value**: `true`
1782 - **Possible values**: `true`, `false`
1784 #### `true` (default):
1802 See also: [`space_before_struct_lit_field_colon`](#space_before_struct_lit_field_colon).
1804 ## `space_after_type_annotation_colon`
1806 Leave a space after the colon in a type annotation
1808 - **Default value**: `true`
1809 - **Possible values**: `true`, `false`
1811 #### `true` (default):
1814 fn lorem<T: Eq>(t: T) {
1815 let ipsum: Dolor = sit;
1822 fn lorem<T: Eq>(t:T) {
1823 let ipsum:Dolor = sit;
1827 See also: [`space_before_type_annotation`](#space_before_type_annotation).
1829 ## `space_before_bound`
1831 Leave a space before the colon in a trait or lifetime bound
1833 - **Default value**: `false`
1834 - **Possible values**: `true`, `false`
1836 #### `false` (default):
1839 fn lorem<T: Eq>(t: T) {
1840 let ipsum: Dolor = sit;
1847 fn lorem<T : Eq>(t: T) {
1848 let ipsum: Dolor = sit;
1852 See also: [`space_after_bound_colon`](#space_after_bound_colon).
1854 ## `space_before_struct_lit_field_colon`
1856 Leave a space before the colon in a struct literal field
1858 - **Default value**: `false`
1859 - **Possible values**: `true`, `false`
1861 #### `false` (default):
1879 See also: [`space_after_struct_lit_field_colon`](#space_after_struct_lit_field_colon).
1881 ## `space_before_type_annotation`
1883 Leave a space before the colon in a type annotation
1885 - **Default value**: `false`
1886 - **Possible values**: `true`, `false`
1888 #### `false` (default):
1891 fn lorem<T: Eq>(t: T) {
1892 let ipsum: Dolor = sit;
1899 fn lorem<T: Eq>(t : T) {
1900 let ipsum : Dolor = sit;
1904 See also: [`space_after_type_annotation_colon`](#space_after_type_annotation_colon).
1906 ## `spaces_around_ranges`
1908 Put spaces around the .. and ... range operators
1910 - **Default value**: `false`
1911 - **Possible values**: `true`, `false`
1913 #### `false` (default):
1922 let lorem = 0 .. 10;
1925 ## `spaces_within_angle_brackets`
1927 Put spaces within non-empty generic arguments
1929 - **Default value**: `false`
1930 - **Possible values**: `true`, `false`
1932 #### `false` (default):
1935 fn lorem<T: Eq>(t: T) {
1943 fn lorem< T: Eq >(t: T) {
1948 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1950 ## `spaces_within_parens`
1952 Put spaces within non-empty parentheses
1954 - **Default value**: `false`
1955 - **Possible values**: `true`, `false`
1957 #### `false` (default):
1960 fn lorem<T: Eq>(t: T) {
1961 let lorem = (ipsum, dolor);
1968 fn lorem<T: Eq>( t: T ) {
1969 let lorem = ( ipsum, dolor );
1973 See also: [`spaces_within_angle_brackets`](#spaces_within_angle_brackets), [`spaces_within_square_brackets`](#spaces_within_square_brackets).
1975 ## `spaces_within_square_brackets`
1977 Put spaces within non-empty square brackets
1979 - **Default value**: `false`
1980 - **Possible values**: `true`, `false`
1982 #### `false` (default):
1985 let lorem: [usize; 2] = [ipsum, dolor];
1991 let lorem: [ usize; 2 ] = [ ipsum, dolor ];
1994 See also: [`spaces_within_parens`](#spaces_within_parens), [`spaces_within_angle_brackets`](#spaces_within_angle_brackets).
1996 ## `struct_lit_multiline_style`
1998 Multiline style on literal structs
2000 - **Default value**: `"PreferSingle"`
2001 - **Possible values**: `"ForceMulti"`, `"PreferSingle"`
2003 #### `"PreferSingle"` (default):
2006 let lorem = Lorem { ipsum: dolor, sit: amet };
2009 #### `"ForceMulti"`:
2018 See also: [`indent_style`](#indent_style), [`struct_lit_width`](#struct_lit_width).
2020 ## `struct_lit_width`
2022 Maximum width in the body of a struct lit before falling back to vertical formatting
2024 - **Default value**: `18`
2025 - **Possible values**: any positive integer
2027 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2029 #### Lines shorter than `struct_lit_width`:
2031 let lorem = Lorem { ipsum: dolor, sit: amet };
2034 #### Lines longer than `struct_lit_width`:
2035 See [`indent_style`](#indent_style).
2037 See also: [`struct_lit_multiline_style`](#struct_lit_multiline_style), [`indent_style`](#indent_style).
2039 ## `struct_variant_width`
2041 Maximum width in the body of a struct variant before falling back to vertical formatting
2043 - **Default value**: `35`
2044 - **Possible values**: any positive integer
2046 **Note:** A value of `0` results in vertical formatting being applied regardless of a line's width.
2048 #### Struct variants shorter than `struct_variant_width`:
2053 Sit { amet: Consectetur, adipiscing: Elit },
2057 #### Struct variants longer than `struct_variant_width`:
2071 Number of spaces per tab
2073 - **Default value**: `4`
2074 - **Possible values**: any positive integer
2080 let ipsum = dolor();
2082 "amet consectetur adipiscing elit."
2091 let ipsum = dolor();
2093 "amet consectetur adipiscing elit."
2098 See also: [`hard_tabs`](#hard_tabs).
2100 ## `take_source_hints`
2102 Retain some formatting characteristics from the source code
2104 - **Default value**: `false`
2105 - **Possible values**: `true`, `false`
2107 #### `false` (default):
2112 .dolor(|| { sit.amet().consectetur().adipiscing().elit(); });
2128 Note: This only applies if the call chain within the inner closure had already been formatted on separate lines before running rustfmt.
2132 How to handle trailing commas for lists
2134 - **Default value**: `"Vertical"`
2135 - **Possible values**: `"Always"`, `"Never"`, `"Vertical"`
2137 #### `"Vertical"` (default):
2140 let Lorem { ipsum, dolor, sit } = amet;
2154 let Lorem { ipsum, dolor, sit, } = amet;
2168 let Lorem { ipsum, dolor, sit } = amet;
2179 See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
2181 ## `trailing_semicolon`
2183 Add trailing semicolon after break, continue and return
2185 - **Default value**: `true`
2186 - **Possible values**: `true`, `false`
2188 #### `true` (default):
2202 ## `type_punctuation_density`
2204 Determines if `+` or `=` are wrapped in spaces in the punctuation of types
2206 - **Default value**: `"Wide"`
2207 - **Possible values**: `"Compressed"`, `"Wide"`
2209 #### `"Wide"` (default):
2212 fn lorem<Ipsum: Dolor + Sit = Amet>() {
2217 #### `"Compressed"`:
2220 fn lorem<Ipsum: Dolor+Sit=Amet>() {
2225 ## `use_try_shorthand`
2227 Replace uses of the try! macro by the ? shorthand
2229 - **Default value**: `false`
2230 - **Possible values**: `true`, `false`
2232 #### `false` (default):
2235 let lorem = try!(ipsum.map(|dolor|dolor.sit()));
2241 let lorem = ipsum.map(|dolor| dolor.sit())?;
2246 Density of a where clause.
2248 - **Default value**: `"Vertical"`
2249 - **Possible values**: `"Compressed"`, `"CompressedIfEmpty"`, `"Tall"`, `"Vertical"`
2251 #### `"Vertical"` (default):
2255 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2259 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2268 **Note:** `where_density = "Vertical"` currently produces the same output as `where_density = "Tall"`.
2270 #### `"CompressedIfEmpty"`:
2274 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2277 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2286 #### `"Compressed"`:
2290 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2293 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2304 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2308 fn ipsum<Dolor>(dolor: Dolor) -> Sit
2317 **Note:** `where_density = "Tall"` currently produces the same output as `where_density = "Vertical"`.
2319 See also: [`where_layout`](#where_layout), [`indent_style`](#indent_style).
2323 Element layout inside a where clause
2325 - **Default value**: `"Vertical"`
2326 - **Possible values**: `"Horizontal"`, `"HorizontalVertical"`, `"Mixed"`, `"Vertical"`
2328 #### `"Vertical"` (default):
2331 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2332 where Ipsum: IpsumDolorSitAmet,
2333 Dolor: DolorSitAmetConsectetur
2338 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2339 where Ipsum: IpsumDolorSitAmet,
2340 Dolor: DolorSitAmetConsectetur,
2341 Sit: SitAmetConsecteturAdipiscing,
2342 Amet: AmetConsecteturAdipiscingElit
2348 #### `"Horizontal"`:
2351 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2352 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2357 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2358 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur, Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2364 #### `"HorizontalVertical"`:
2367 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2368 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2373 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2374 where Ipsum: IpsumDolorSitAmet,
2375 Dolor: DolorSitAmetConsectetur,
2376 Sit: SitAmetConsecteturAdipiscing,
2377 Amet: AmetConsecteturAdipiscingElit
2386 fn lorem<Ipsum, Dolor>(ipsum: Ipsum, dolor: Dolor)
2387 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur
2392 fn lorem<Ipsum, Dolor, Sit, Amet>(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet)
2393 where Ipsum: IpsumDolorSitAmet, Dolor: DolorSitAmetConsectetur,
2394 Sit: SitAmetConsecteturAdipiscing, Amet: AmetConsecteturAdipiscingElit
2400 See also: [`where_density`](#where_density), [`indent_style`](#indent_style).
2404 Break comments to fit on the line
2406 - **Default value**: `false`
2407 - **Possible values**: `true`, `false`
2409 #### `false` (default):
2412 // 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.
2418 // Lorem ipsum dolor sit amet, consectetur adipiscing elit,
2419 // sed do eiusmod tempor incididunt ut labore et dolore
2420 // magna aliqua. Ut enim ad minim veniam, quis nostrud
2421 // exercitation ullamco laboris nisi ut aliquip ex ea
2422 // commodo consequat.
2425 ## `wrap_match_arms`
2427 Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms
2429 - **Default value**: `true`
2430 - **Possible values**: `true`, `false`
2432 #### `true` (default):
2437 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
2439 false => println!("{}", sit),
2448 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
2449 false => println!("{}", sit),
2453 See also: [`indent_match_arms`](#indent_match_arms), [`match_block_trailing_comma`](#match_block_trailing_comma).
2457 What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage
2459 - **Default value**: `"Overwrite"`
2460 - **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`