X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=Configurations.md;h=6fcd0609b6569912c96977412f3307b9492e95c5;hb=01c14a2058924390543f072aeb5955a8d179df36;hp=1cf3b8ec71810a3e538b2d103707b6a3473d89b0;hpb=9212ae7d026480a9e7a6e363da32a6bc73849457;p=rust.git diff --git a/Configurations.md b/Configurations.md index 1cf3b8ec718..6fcd0609b65 100644 --- a/Configurations.md +++ b/Configurations.md @@ -276,8 +276,8 @@ fn lorem() -> T Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small'. - **Default value**: `Default` -- **Possible values**: `Default`, `Off` -- **Stable**: Yess +- **Possible values**: `Default`, `Off`, `Max` +- **Stable**: Yes #### `Default` (default): @@ -337,6 +337,24 @@ fn main() { } ``` +#### `Max`: + +```rust +enum Lorem { + Ipsum, + Dolor(bool), + Sit { amet: Consectetur, adipiscing: Elit }, +} + +fn main() { + lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing"); + + let lorem = Lorem { ipsum: dolor, sit: amet }; + + let lorem = if ipsum { dolor } else { sit }; +} +``` + ## `binop_separator` Where to put a binary operator when a binary expression goes multiline. @@ -988,6 +1006,76 @@ fn main() { See also [`max_width`](#max_width). +## `format_macro_matchers` + +Format the metavariable matching patterns in macros. + +- **Default value**: `false` +- **Possible values**: `true`, `false` +- **Stable**: No + +#### `false` (default): + +```rust +macro_rules! foo { + ($a: ident : $b: ty) => { + $a(42): $b; + }; + ($a: ident $b: ident $c: ident) => { + $a = $b + $c; + }; +} +``` + +#### `true`: + +```rust +macro_rules! foo { + ($a:ident : $b:ty) => { + $a(42): $b; + }; + ($a:ident $b:ident $c:ident) => { + $a = $b + $c; + }; +} +``` + +See also [`format_macro_bodies`](#format_macro_bodies). + + +## `format_macro_bodies` + +Format the bodies of macros. + +- **Default value**: `true` +- **Possible values**: `true`, `false` +- **Stable**: No + +#### `true` (default): + +```rust +macro_rules! foo { + ($a: ident : $b: ty) => { + $a(42): $b; + }; + ($a: ident $b: ident $c: ident) => { + $a = $b + $c; + }; +} +``` + +#### `false`: + +```rust +macro_rules! foo { + ($a: ident : $b: ty) => { $a(42): $b; }; + ($a: ident $b: ident $c: ident) => { $a=$b+$c; }; +} +``` + +See also [`format_macro_matchers`](#format_macro_matchers). + + ## `hard_tabs` Use tab characters for indentation, spaces for alignment @@ -1019,18 +1107,11 @@ See also: [`tab_spaces`](#tab_spaces). Indent style of imports -- **Default Value**: `"Visual"` +- **Default Value**: `"Block"` - **Possible values**: `"Block"`, `"Visual"` - **Stable**: No -#### `"Visual"` (default): - -```rust -use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy, - zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz}; -``` - -#### `"Block"`: +#### `"Block"` (default): ```rust use foo::{ @@ -1039,6 +1120,13 @@ use foo::{ }; ``` +#### `"Visual"`: + +```rust +use foo::{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy, + zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz}; +``` + See also: [`imports_layout`](#imports_layout). ## `imports_layout` @@ -1215,7 +1303,7 @@ fn main() { }); match lorem { - None => if ipsum { + None => |ipsum| { println!("Hello World"); }, Some(dolor) => foo(), @@ -1236,7 +1324,7 @@ fn main() { match lorem { None => { - if ipsum { + |ipsum| { println!("Hello World"); } } @@ -1250,10 +1338,29 @@ fn main() { Unix or Windows line endings -- **Default value**: `"Unix"` -- **Possible values**: `"Native"`, `"Unix"`, `"Windows"` +- **Default value**: `"Auto"` +- **Possible values**: `"Auto"`, `"Native"`, `"Unix"`, `"Windows"` - **Stable**: Yes +#### `Auto` (default): + +The newline style is detected automatically on a per-file basis. Files +with mixed line endings will be converted to the first detected line +ending style. + +#### `Native` + +Line endings will be converted to `\r\n` on Windows and `\n` on all +other platforms. + +#### `Unix` + +Line endings will be converted to `\n`. + +#### `Windows` + +Line endings will be converted to `\r\n`. + ## `normalize_comments` Convert /* */ comments to // comments where possible @@ -2060,11 +2167,27 @@ ignore = [ If you want to ignore every file under `examples/`, put the following to your config file: ```toml -ignore [ +ignore = [ "examples", ] ``` +## `edition` + +Specifies which edition is used by the parser. + +- **Default value**: `2015` +- **Possible values**: `2015`, `2018` +- **Stable**: No + +### Example + +If you want to format code that requires edition 2018, add the following to your config file: + +```toml +edition = "2018" +``` + ## `emit_mode` Internal option