mirror of
https://github.com/starship/starship.git
synced 2024-12-26 09:08:53 +01: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:
parent
1c3bae29d3
commit
6000231d12
@ -22,7 +22,7 @@ impl<'a> Default for FossilBranchConfig<'a> {
|
||||
format: "on [$symbol$branch]($style) ",
|
||||
symbol: " ",
|
||||
style: "bold purple",
|
||||
truncation_length: std::i64::MAX,
|
||||
truncation_length: i64::MAX,
|
||||
truncation_symbol: "…",
|
||||
disabled: true,
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl<'a> Default for GitBranchConfig<'a> {
|
||||
format: "on [$symbol$branch(:$remote_branch)]($style) ",
|
||||
symbol: " ",
|
||||
style: "bold purple",
|
||||
truncation_length: std::i64::MAX,
|
||||
truncation_length: i64::MAX,
|
||||
truncation_symbol: "…",
|
||||
only_attached: false,
|
||||
always_show_remote: false,
|
||||
|
@ -22,7 +22,7 @@ impl<'a> Default for HgBranchConfig<'a> {
|
||||
symbol: " ",
|
||||
style: "bold purple",
|
||||
format: "on [$symbol$branch(:$topic)]($style) ",
|
||||
truncation_length: std::i64::MAX,
|
||||
truncation_length: i64::MAX,
|
||||
truncation_symbol: "…",
|
||||
disabled: true,
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ pub struct MesonConfig<'a> {
|
||||
impl<'a> Default for MesonConfig<'a> {
|
||||
fn default() -> Self {
|
||||
MesonConfig {
|
||||
truncation_length: std::u32::MAX,
|
||||
truncation_length: u32::MAX,
|
||||
truncation_symbol: "…",
|
||||
format: "via [$symbol$project]($style) ",
|
||||
symbol: "⬢ ",
|
||||
|
@ -22,7 +22,7 @@ impl<'a> Default for PijulConfig<'a> {
|
||||
symbol: " ",
|
||||
style: "bold purple",
|
||||
format: "on [$symbol$channel]($style) ",
|
||||
truncation_length: std::i64::MAX,
|
||||
truncation_length: i64::MAX,
|
||||
truncation_symbol: "…",
|
||||
disabled: true,
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
"\"truncation_length\" should be a positive value, found {}",
|
||||
config.truncation_length
|
||||
);
|
||||
std::usize::MAX
|
||||
usize::MAX
|
||||
} else {
|
||||
config.truncation_length as usize
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
"\"truncation_length\" should be a positive value, found {}",
|
||||
config.truncation_length
|
||||
);
|
||||
std::usize::MAX
|
||||
usize::MAX
|
||||
} else {
|
||||
config.truncation_length as usize
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -26,7 +26,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
"\"truncation_length\" should be a positive value, found {}",
|
||||
config.truncation_length
|
||||
);
|
||||
std::usize::MAX
|
||||
usize::MAX
|
||||
} else {
|
||||
config.truncation_length as usize
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user