1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Opinionated whitespace and tabs. The most important of these are imports and width settings.
# Others may want to borrow or change these to their own liking.
# https://rust-lang.github.io/rustfmt
# version-related
="2021" # redundant, fmt will read Cargo.toml for editor edition year
=true
=true # replace any `try!` (2015 Rust) with `?`
# misc formatting
=true # replace: (a,b,_,_)=(1, 2, 3, 4); -> (a,b,..)=(1, 2, 3, 4);
=true # format code blocks in doc comments
=true # $a: ident -> $a:ident
=true # break and insert newlines for long string literals
=true # include comma in match blocks after '}'
=true # convert /*..*/ to //.. where possible
=true # move `type` and `const` declarations to top of impl block
=20 # align struct arguments' types vertically
=true # struct initialization short {x: x} -> {x}
# reduce whitespace
=1 # default: 1. Sometimes useful to change to 0 to condense a file.
="PreferSameLine" # prefer starting `{` without inserting extra \n
=true # if it's a short 1-liner, let it be a short 1-liner
=false # remove unnecessary {} in match arms
="Unix" # not auto, we won the culture war. \n over \r\n
=true # prefer ]); to ]\n);
=true # put where on a single line if possible
# imports preferences
="StdExternalCrate" # create import groupings for std, external libs, and internal deps
="Crate" # aggressively group imports
# width settings: everything to 100
=100 # default: 80
=60 # inlines #[cfg(test)]\nmod test -> #[cfg(test)] mod test
=100 # default: 100
="Max" # don't ever newline short of `max_width`.
=true # wrap comments at `comment_width`
# format_strings = true # wrap strings at `max_length`
# tabs and spaces
=false # (def: false) use spaces over tabs
=2 # 2 > 4, it's just math.