Skip to content

Commit

Permalink
fmt: Specify format config (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
oissevalt authored Oct 21, 2024
1 parent f472ac1 commit cb46289
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`).

Expand Down
13 changes: 3 additions & 10 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CliArgs> = LazyLock::new(|| CliArgs::parse());
4 changes: 2 additions & 2 deletions src/decompress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub fn decompress<P>(src: P, dest: P) -> Result<(), Box<dyn Error>>
where
P: AsRef<Path>,
{
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) {
Expand Down

0 comments on commit cb46289

Please sign in to comment.