From d9b26b1f952a9f7991fcff4353a1d6f464cb7400 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 7 Jan 2024 16:59:33 +0800 Subject: [PATCH] RFC: proposed rustfmt settings for the project --- .vscode/settings.json | 3 +++ rustfmt.toml | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 87327e126..4a39a6a4b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,5 +23,8 @@ "**/.DS_Store": true, "**/Thumbs.db": true }, + "rust-analyzer.rustfmt.extraArgs": [ + "+nightly" + ], "cSpell.language": "en,fr" } diff --git a/rustfmt.toml b/rustfmt.toml index 58e3e66e0..976c1dd93 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -15,6 +15,43 @@ ignore = [ "services/shellchat", "services/spinor", "services/susres", + "services/pddb", ] -# Note: run this on Linux to fix Windows changing .rs files to +x: -# find . -name "*.rs" -exec chmod -x {} \; \ No newline at end of file +# Notes: +# - @generated in the first five lines of a file suppresses formatting for generated files! +# - run this on Linux to fix Windows changing .rs files to +x: +# `find . -name "*.rs" -exec chmod -x {} \;` + +# I can't rely on contributors using .editorconfig +newline_style = "Unix" +# require the shorthand instead of it being optional +use_field_init_shorthand = true +# outdated default — `?` was unstable at the time +# additionally the `try!` macro is deprecated now +use_try_shorthand = true +# Computers in the 90's had 132 column displays[1], and the displays were 1/6th the area. +# 110 columns doesn't seem like a big stretch... +# [1] https://en.wikipedia.org/wiki/VGA_text_mode +max_width = 110 +# Max to use the max width for everything or Default. See https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics +use_small_heuristics = "Max" + +# Unstable features below +unstable_features = true +version = "Two" +# code can be 110 characters, why not comments? +comment_width = 110 +# quicker manual lookup +group_imports = "StdExternalCrate" +# why use an attribute if a normal doc comment would suffice? +normalize_doc_attributes = true +# why not? +format_code_in_doc_comments = true +format_macro_bodies = true +format_macro_matchers = true +format_strings = false +wrap_comments = true +fn_single_line = true +reorder_impl_items = true +reorder_imports = false +reorder_modules = false