From a8cf86772c673e3e6c248f0b2c73ccd83d41927c Mon Sep 17 00:00:00 2001 From: Olivier FAURE Date: Tue, 14 May 2024 11:46:59 +0200 Subject: [PATCH] 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 --- rustfmt.toml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..9b125bc6 --- /dev/null +++ b/rustfmt.toml @@ -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"