From cb4628910c3e831945dbac084e90d76872dd1e64 Mon Sep 17 00:00:00 2001 From: PrecoGodder <57583509+oissevalt@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:21:54 +0100 Subject: [PATCH] fmt: Specify format config (#2) --- .rustfmt.toml | 5 +++++ README.md | 2 +- src/consts.rs | 13 +++---------- src/decompress/mod.rs | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..b4c1316 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,5 @@ +max_width = 90 +newline_style = "Unix" +single_line_if_else_max_width = 80 +single_line_let_else_max_width = 80 +edition = "2021" diff --git a/README.md b/README.md index 8ada1c6..c0d0e03 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ For a full definition of acceptable arguments and flags, see `src/cli.rs`. ## Style Guides -1. Use `cargo fmt` without any options to format the project. Do not use `rustfmt` as it formats on a per-file basis and removes disambiguate imports. +1. Use `cargo fmt` with configurations speficied in `.rustfmt.toml` to format the project. Do not run `rustfmt` directly as it formats on a per-file basis and may remove disambiguate imports. 2. Import types directly; prefer `File` instead of `std::fs::File` or `fs::File`, unless ambiguity forbids (`Error` and `io::Error`). diff --git a/src/consts.rs b/src/consts.rs index e3acf42..23cfde6 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -7,18 +7,11 @@ use clap::Parser; use crate::cli::CliArgs; /// The name of SealDice executable. -pub const EXE_NAME: &str = if cfg!(windows) { - "sealdice-core.exe" -} else { - "sealdice-core" -}; +pub const EXE_NAME: &str = + if cfg!(windows) { "sealdice-core.exe" } else { "sealdice-core" }; /// The name of this program. -pub const UPD_NAME: &str = if cfg!(windows) { - "sealupd.exe" -} else { - "sealupd" -}; +pub const UPD_NAME: &str = if cfg!(windows) { "sealupd.exe" } else { "sealupd" }; /// The command-line arguments accepted from the caller. pub static CLI_ARGS: LazyLock = LazyLock::new(|| CliArgs::parse()); diff --git a/src/decompress/mod.rs b/src/decompress/mod.rs index a396d20..dee9739 100644 --- a/src/decompress/mod.rs +++ b/src/decompress/mod.rs @@ -20,8 +20,8 @@ pub fn decompress

(src: P, dest: P) -> Result<(), Box> where P: AsRef, { - let mut file = - File::open(src.as_ref()).map_err(|e| format!("open {:?}: {}", src.as_ref(), e))?; + let mut file = File::open(src.as_ref()) + .map_err(|e| format!("open {:?}: {}", src.as_ref(), e))?; let dest = dest.as_ref(); if let Err(err) = zip::decompress(&mut file, dest) {