chore: Minor changes to use more idiomatic Rust (integer max values; complicates nested expressions) (#6090)

* chore: use current way to get max value of an integer type

The std::usize::MAX way has been obsolete for quite some time now.
Found by clippy (clippy::legacy_numeric_constants).

Signed-off-by: Lars Wirzenius <liw@liw.fi>

* chore: use helper variable for a more idiomatic pattern matching

A nested expression can be harder to understand than two simpler
expressions. (Found by clippy lint clippy::blocks_in_conditions.)

Signed-off-by: Lars Wirzenius <liw@liw.fi>

---------

Signed-off-by: Lars Wirzenius <liw@liw.fi>
Co-authored-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
larswirzenius
2024-07-24 22:06:40 +03:00
committed by GitHub
parent 1c3bae29d3
commit 6000231d12
9 changed files with 15 additions and 14 deletions
+7 -6
View File
@@ -426,13 +426,13 @@ fn git_status_wsl(context: &Context, conf: &GitStatusConfig) -> Option<String> {
log::trace!("Using WSL mode");
// Get Windows path
let winpath = match create_command("wslpath")
let wslpath = create_command("wslpath")
.map(|mut c| {
c.arg("-w").arg(&context.current_dir);
c
})
.and_then(|mut c| c.output())
{
.and_then(|mut c| c.output());
let winpath = match wslpath {
Ok(r) => r,
Err(e) => {
// Not found might means this might not be WSL after all
@@ -472,7 +472,7 @@ fn git_status_wsl(context: &Context, conf: &GitStatusConfig) -> Option<String> {
|e| e + ":STARSHIP_CONFIG/wp",
);
let out = match create_command(starship_exe)
let exe = create_command(starship_exe)
.map(|mut c| {
c.env(
"STARSHIP_CONFIG",
@@ -484,8 +484,9 @@ fn git_status_wsl(context: &Context, conf: &GitStatusConfig) -> Option<String> {
.args(["module", "git_status", "--path", winpath]);
c
})
.and_then(|mut c| c.output())
{
.and_then(|mut c| c.output());
let out = match exe {
Ok(r) => r,
Err(e) => {
log::error!("Failed to run Git Status module on Windows:\n{}", e);