mirror of
https://github.com/starship/starship.git
synced 2026-06-24 02:01:36 +07:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user