1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-14 19:16:17 +00:00

clippy: fix some "unnested or-patterns" warnings

This commit is contained in:
Daniel Hofstetter 2022-12-20 16:07:37 +01:00
parent 03710a180e
commit a0522f5cbd
8 changed files with 36 additions and 44 deletions

View file

@ -81,8 +81,7 @@ impl SplitName {
* zero padding
*/
// decimal
("0", "d") | ("0", "i") | ("0", "u") => {
Box::new(move |n: usize| -> String {
("0", "d" | "i" | "u") => Box::new(move |n: usize| -> String {
format!(
"{}{}{:0width$}{}",
prefix,
@ -91,8 +90,7 @@ impl SplitName {
after,
width = n_digits
)
})
}
}),
// octal
("0", "o") => Box::new(move |n: usize| -> String {
format!(
@ -168,8 +166,7 @@ impl SplitName {
* Left adjusted
*/
// decimal
("-", "d") | ("-", "i") | ("-", "u") => {
Box::new(move |n: usize| -> String {
("-", "d" | "i" | "u") => Box::new(move |n: usize| -> String {
format!(
"{}{}{:<#width$}{}",
prefix,
@ -178,8 +175,7 @@ impl SplitName {
after,
width = n_digits
)
})
}
}),
// octal
("-", "o") => Box::new(move |n: usize| -> String {
format!(

View file

@ -505,7 +505,7 @@ fn parse_bytes_no_x(full: &str, s: &str) -> Result<u64, ParseError> {
let (num, multiplier) = match (s.find('c'), s.rfind('w'), s.rfind('b')) {
(None, None, None) => match parser.parse(s) {
Ok(n) => (n, 1),
Err(ParseSizeError::InvalidSuffix(_)) | Err(ParseSizeError::ParseFailure(_)) => {
Err(ParseSizeError::InvalidSuffix(_) | ParseSizeError::ParseFailure(_)) => {
return Err(ParseError::InvalidNumber(full.to_string()))
}
Err(ParseSizeError::SizeTooBig(_)) => {

View file

@ -135,7 +135,7 @@ impl FromStr for FormatOptions {
}
// GNU numfmt allows to mix the characters " ", "'", and "0" in any way, so we do the same
while matches!(iter.peek(), Some(' ') | Some('\'') | Some('0')) {
while matches!(iter.peek(), Some(' ' | '\'' | '0')) {
match iter.next().unwrap() {
' ' => (),
'\'' => options.grouping = true,
@ -178,7 +178,7 @@ impl FromStr for FormatOptions {
if let Some('.') = iter.peek() {
iter.next();
if matches!(iter.peek(), Some(' ') | Some('+') | Some('-')) {
if matches!(iter.peek(), Some(' ' | '+' | '-')) {
return Err(format!("invalid precision in format '{}'", s));
}

View file

@ -55,28 +55,26 @@ fn od_format_type(type_char: FormatType, byte_size: u8) -> Option<FormatterItemI
(FormatType::DecimalInt, 1) => Some(FORMAT_ITEM_DEC8S),
(FormatType::DecimalInt, 2) => Some(FORMAT_ITEM_DEC16S),
(FormatType::DecimalInt, 0) | (FormatType::DecimalInt, 4) => Some(FORMAT_ITEM_DEC32S),
(FormatType::DecimalInt, 0 | 4) => Some(FORMAT_ITEM_DEC32S),
(FormatType::DecimalInt, 8) => Some(FORMAT_ITEM_DEC64S),
(FormatType::OctalInt, 1) => Some(FORMAT_ITEM_OCT8),
(FormatType::OctalInt, 2) => Some(FORMAT_ITEM_OCT16),
(FormatType::OctalInt, 0) | (FormatType::OctalInt, 4) => Some(FORMAT_ITEM_OCT32),
(FormatType::OctalInt, 0 | 4) => Some(FORMAT_ITEM_OCT32),
(FormatType::OctalInt, 8) => Some(FORMAT_ITEM_OCT64),
(FormatType::UnsignedInt, 1) => Some(FORMAT_ITEM_DEC8U),
(FormatType::UnsignedInt, 2) => Some(FORMAT_ITEM_DEC16U),
(FormatType::UnsignedInt, 0) | (FormatType::UnsignedInt, 4) => Some(FORMAT_ITEM_DEC32U),
(FormatType::UnsignedInt, 0 | 4) => Some(FORMAT_ITEM_DEC32U),
(FormatType::UnsignedInt, 8) => Some(FORMAT_ITEM_DEC64U),
(FormatType::HexadecimalInt, 1) => Some(FORMAT_ITEM_HEX8),
(FormatType::HexadecimalInt, 2) => Some(FORMAT_ITEM_HEX16),
(FormatType::HexadecimalInt, 0) | (FormatType::HexadecimalInt, 4) => {
Some(FORMAT_ITEM_HEX32)
}
(FormatType::HexadecimalInt, 0 | 4) => Some(FORMAT_ITEM_HEX32),
(FormatType::HexadecimalInt, 8) => Some(FORMAT_ITEM_HEX64),
(FormatType::Float, 2) => Some(FORMAT_ITEM_F16),
(FormatType::Float, 0) | (FormatType::Float, 4) => Some(FORMAT_ITEM_F32),
(FormatType::Float, 0 | 4) => Some(FORMAT_ITEM_F32),
(FormatType::Float, 8) => Some(FORMAT_ITEM_F64),
_ => None,

View file

@ -20,11 +20,11 @@ pub fn parse_number_of_bytes(s: &str) -> Result<u64, ParseSizeError> {
multiply = 512;
len -= 1;
}
Some('k') | Some('K') => {
Some('k' | 'K') => {
multiply = 1024;
len -= 1;
}
Some('m') | Some('M') => {
Some('m' | 'M') => {
multiply = 1024 * 1024;
len -= 1;
}
@ -50,8 +50,8 @@ pub fn parse_number_of_bytes(s: &str) -> Result<u64, ParseSizeError> {
Some('B') if radix != 16 => {
len -= 2;
multiply = match ends_with.next() {
Some('k') | Some('K') => 1000,
Some('m') | Some('M') => 1000 * 1000,
Some('k' | 'K') => 1000,
Some('m' | 'M') => 1000 * 1000,
Some('G') => 1000 * 1000 * 1000,
#[cfg(target_pointer_width = "64")]
Some('T') => 1000 * 1000 * 1000 * 1000,

View file

@ -1201,7 +1201,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
matches
.get_one::<String>(options::check::CHECK)
.map(|s| s.as_str()),
Some(options::check::SILENT) | Some(options::check::QUIET)
Some(options::check::SILENT | options::check::QUIET)
)
{
settings.check_silent = true;
@ -1695,7 +1695,7 @@ fn get_leading_gen(input: &str) -> Range<usize> {
let first = char_indices.peek();
if matches!(first, Some((_, NEGATIVE)) | Some((_, POSITIVE))) {
if matches!(first, Some((_, NEGATIVE) | (_, POSITIVE))) {
char_indices.next();
}

View file

@ -233,9 +233,7 @@ fn open(
Err(f) => {
show_error!("{}: {}", name.maybe_quote(), f);
match output_error {
Some(OutputErrorMode::Exit) | Some(OutputErrorMode::ExitNoPipe) => {
return Err(f)
}
Some(OutputErrorMode::Exit | OutputErrorMode::ExitNoPipe) => return Err(f),
_ => Box::new(sink()),
}
}

View file

@ -67,7 +67,7 @@ impl FloatAnalysis {
let mut pos_before_first_nonzero_after_decimal: Option<usize> = None;
for c in str_it {
match c {
e @ '0'..='9' | e @ 'A'..='F' | e @ 'a'..='f' => {
e @ ('0'..='9' | 'A'..='F' | 'a'..='f') => {
if !hex_input {
match e {
'0'..='9' => {}