mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
fix(clippy): if_not_else
This commit is contained in:
parent
dc72ad9242
commit
a7ae477a7e
4 changed files with 19 additions and 19 deletions
|
@ -1091,13 +1091,13 @@ impl Config {
|
||||||
Dereference::DirArgs
|
Dereference::DirArgs
|
||||||
};
|
};
|
||||||
|
|
||||||
let tab_size = if !needs_color {
|
let tab_size = if needs_color {
|
||||||
|
Some(0)
|
||||||
|
} else {
|
||||||
options
|
options
|
||||||
.get_one::<String>(options::format::TAB_SIZE)
|
.get_one::<String>(options::format::TAB_SIZE)
|
||||||
.and_then(|size| size.parse::<usize>().ok())
|
.and_then(|size| size.parse::<usize>().ok())
|
||||||
.or_else(|| std::env::var("TABSIZE").ok().and_then(|s| s.parse().ok()))
|
.or_else(|| std::env::var("TABSIZE").ok().and_then(|s| s.parse().ok()))
|
||||||
} else {
|
|
||||||
Some(0)
|
|
||||||
}
|
}
|
||||||
.unwrap_or(SPACES_IN_TAB);
|
.unwrap_or(SPACES_IN_TAB);
|
||||||
|
|
||||||
|
|
|
@ -736,16 +736,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.flatten()
|
.flatten()
|
||||||
.cloned();
|
.cloned();
|
||||||
|
|
||||||
if !config.gnu_ext {
|
if config.gnu_ext {
|
||||||
input_files = vec![files.next().unwrap_or("-".to_string())];
|
|
||||||
output_file = files.next().unwrap_or("-".to_string());
|
|
||||||
if let Some(file) = files.next() {
|
|
||||||
return Err(UUsageError::new(
|
|
||||||
1,
|
|
||||||
format!("extra operand {}", file.quote()),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
input_files = {
|
input_files = {
|
||||||
let mut files = files.collect::<Vec<_>>();
|
let mut files = files.collect::<Vec<_>>();
|
||||||
if files.is_empty() {
|
if files.is_empty() {
|
||||||
|
@ -754,6 +745,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
files
|
files
|
||||||
};
|
};
|
||||||
output_file = "-".to_string();
|
output_file = "-".to_string();
|
||||||
|
} else {
|
||||||
|
input_files = vec![files.next().unwrap_or("-".to_string())];
|
||||||
|
output_file = files.next().unwrap_or("-".to_string());
|
||||||
|
if let Some(file) = files.next() {
|
||||||
|
return Err(UUsageError::new(
|
||||||
|
1,
|
||||||
|
format!("extra operand {}", file.quote()),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let word_filter = WordFilter::new(&matches, &config)?;
|
let word_filter = WordFilter::new(&matches, &config)?;
|
||||||
|
|
|
@ -328,14 +328,14 @@ impl Formatter<&ExtendedBigDecimal> for Float {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_sign_indicator(sign: PositiveSign, negative: bool) -> String {
|
fn get_sign_indicator(sign: PositiveSign, negative: bool) -> String {
|
||||||
if !negative {
|
if negative {
|
||||||
|
String::from("-")
|
||||||
|
} else {
|
||||||
match sign {
|
match sign {
|
||||||
PositiveSign::None => String::new(),
|
PositiveSign::None => String::new(),
|
||||||
PositiveSign::Plus => String::from("+"),
|
PositiveSign::Plus => String::from("+"),
|
||||||
PositiveSign::Space => String::from(" "),
|
PositiveSign::Space => String::from(" "),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
String::from("-")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -638,13 +638,13 @@ pub(crate) fn parse<'a>(
|
||||||
|
|
||||||
// Return what has been parsed so far. If there are extra characters, mark the
|
// Return what has been parsed so far. If there are extra characters, mark the
|
||||||
// parsing as a partial match.
|
// parsing as a partial match.
|
||||||
if !rest.is_empty() {
|
if rest.is_empty() {
|
||||||
|
ebd_result
|
||||||
|
} else {
|
||||||
Err(ExtendedParserError::PartialMatch(
|
Err(ExtendedParserError::PartialMatch(
|
||||||
ebd_result.unwrap_or_else(|e| e.extract()),
|
ebd_result.unwrap_or_else(|e| e.extract()),
|
||||||
rest,
|
rest,
|
||||||
))
|
))
|
||||||
} else {
|
|
||||||
ebd_result
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue