mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 15:22:38 +00:00
Fix clippy warning match_bool
This commit is contained in:
parent
d7434d4198
commit
2fe5dc874e
5 changed files with 43 additions and 36 deletions
|
@ -1065,10 +1065,13 @@ impl Options {
|
|||
#[cfg(unix)]
|
||||
fn preserve_mode(&self) -> (bool, bool) {
|
||||
match self.attributes.mode {
|
||||
Preserve::No { explicit } => match explicit {
|
||||
true => (false, true),
|
||||
false => (false, false),
|
||||
},
|
||||
Preserve::No { explicit } => {
|
||||
if explicit {
|
||||
(false, true)
|
||||
} else {
|
||||
(false, false)
|
||||
}
|
||||
}
|
||||
Preserve::Yes { .. } => (true, false),
|
||||
}
|
||||
}
|
||||
|
@ -2034,9 +2037,10 @@ fn handle_no_preserve_mode(options: &Options, org_mode: u32) -> u32 {
|
|||
{
|
||||
const MODE_RW_UGO: u32 = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||
const S_IRWXUGO: u32 = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
match is_explicit_no_preserve_mode {
|
||||
true => return MODE_RW_UGO,
|
||||
false => return org_mode & S_IRWXUGO,
|
||||
if is_explicit_no_preserve_mode {
|
||||
return MODE_RW_UGO;
|
||||
} else {
|
||||
return org_mode & S_IRWXUGO;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2051,9 +2055,10 @@ fn handle_no_preserve_mode(options: &Options, org_mode: u32) -> u32 {
|
|||
const MODE_RW_UGO: u32 =
|
||||
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32;
|
||||
const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32;
|
||||
match is_explicit_no_preserve_mode {
|
||||
true => return MODE_RW_UGO,
|
||||
false => return org_mode & S_IRWXUGO,
|
||||
if is_explicit_no_preserve_mode {
|
||||
return MODE_RW_UGO;
|
||||
} else {
|
||||
return org_mode & S_IRWXUGO;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,10 +408,13 @@ fn get_delimiters(
|
|||
}
|
||||
}
|
||||
}
|
||||
None => match whitespace_delimited {
|
||||
true => Delimiter::Whitespace,
|
||||
false => Delimiter::default(),
|
||||
},
|
||||
None => {
|
||||
if whitespace_delimited {
|
||||
Delimiter::Whitespace
|
||||
} else {
|
||||
Delimiter::default()
|
||||
}
|
||||
}
|
||||
};
|
||||
let out_delim = matches
|
||||
.get_one::<OsString>(options::OUTPUT_DELIMITER)
|
||||
|
|
|
@ -763,9 +763,10 @@ fn extract_indicator_style(options: &clap::ArgMatches) -> IndicatorStyle {
|
|||
}
|
||||
|
||||
fn parse_width(s: &str) -> Result<u16, LsError> {
|
||||
let radix = match s.starts_with('0') && s.len() > 1 {
|
||||
true => 8,
|
||||
false => 10,
|
||||
let radix = if s.starts_with('0') && s.len() > 1 {
|
||||
8
|
||||
} else {
|
||||
10
|
||||
};
|
||||
match u16::from_str_radix(s, radix) {
|
||||
Ok(x) => Ok(x),
|
||||
|
|
|
@ -202,15 +202,14 @@ fn send_signal(process: &mut Child, signal: usize, foreground: bool) {
|
|||
// NOTE: GNU timeout doesn't check for errors of signal.
|
||||
// The subprocess might have exited just after the timeout.
|
||||
// Sending a signal now would return "No such process", but we should still try to kill the children.
|
||||
match foreground {
|
||||
true => _ = process.send_signal(signal),
|
||||
false => {
|
||||
_ = process.send_signal_group(signal);
|
||||
let kill_signal = signal_by_name_or_value("KILL").unwrap();
|
||||
let continued_signal = signal_by_name_or_value("CONT").unwrap();
|
||||
if signal != kill_signal && signal != continued_signal {
|
||||
_ = process.send_signal_group(continued_signal);
|
||||
}
|
||||
if foreground {
|
||||
let _ = process.send_signal(signal);
|
||||
} else {
|
||||
let _ = process.send_signal_group(signal);
|
||||
let kill_signal = signal_by_name_or_value("KILL").unwrap();
|
||||
let continued_signal = signal_by_name_or_value("CONT").unwrap();
|
||||
if signal != kill_signal && signal != continued_signal {
|
||||
_ = process.send_signal_group(continued_signal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,10 +217,7 @@ impl Spec {
|
|||
if *c == b'u' && flags.hash {
|
||||
return Err(&start[..index]);
|
||||
}
|
||||
let prefix = match flags.hash {
|
||||
false => Prefix::No,
|
||||
true => Prefix::Yes,
|
||||
};
|
||||
let prefix = if flags.hash { Prefix::Yes } else { Prefix::No };
|
||||
let variant = match c {
|
||||
b'u' => UnsignedIntVariant::Decimal,
|
||||
b'o' => UnsignedIntVariant::Octal(prefix),
|
||||
|
@ -245,13 +242,15 @@ impl Spec {
|
|||
b'a' | b'A' => FloatVariant::Hexadecimal,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
force_decimal: match flags.hash {
|
||||
false => ForceDecimal::No,
|
||||
true => ForceDecimal::Yes,
|
||||
force_decimal: if flags.hash {
|
||||
ForceDecimal::Yes
|
||||
} else {
|
||||
ForceDecimal::No
|
||||
},
|
||||
case: match c.is_ascii_uppercase() {
|
||||
false => Case::Lowercase,
|
||||
true => Case::Uppercase,
|
||||
case: if c.is_ascii_uppercase() {
|
||||
Case::Uppercase
|
||||
} else {
|
||||
Case::Lowercase
|
||||
},
|
||||
alignment,
|
||||
positive_sign,
|
||||
|
|
Loading…
Reference in a new issue