Add rustfmt config (#305)

These standardized options can make code a little nicer. Right now they
don't change anything, though they include an implicit commitment to
adopt the # `imports_granularity = "Module"` and `group_imports =
"StdExternalCrate"` settings.

While these settings are unstable, we can apply them with rustfmt
nightly without actually committing to using nightly in CI. We should
progressively move parts of the codebase towards that format in future
PRs.

---------

Co-authored-by: Kaur Kuut <strom@nevermore.ee>
This commit is contained in:
Olivier FAURE 2024-05-14 11:46:59 +02:00 committed by GitHub
parent eef5a23905
commit a8cf86772c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 0 deletions

17
rustfmt.toml Normal file
View File

@ -0,0 +1,17 @@
# See https://rust-lang.github.io/rustfmt for more information
# Ensure lines end with \n even if the git configuration core.autocrlf is not set to true
newline_style = "Unix"
# `Foobar { foo, bar }` is more readable than `Foo { foo: foo, bar: bar }`
use_field_init_shorthand = true
# Forces let else blocks to always be their own line(s)
single_line_let_else_max_width = 0
# Subjectively, this combo improves readability on imports. The full prefix is always
# visible right after `use`, and different types of imports are grouped together in
# a predictable way (first std, then other crates, then local imports).
# (These options are still unstable and thus commented out)
# imports_granularity = "Module"
# group_imports = "StdExternalCrate"