mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
fix(clippy): if_not_else
This commit is contained in:
+3
-3
@@ -1091,13 +1091,13 @@ impl Config {
|
||||
Dereference::DirArgs
|
||||
};
|
||||
|
||||
let tab_size = if !needs_color {
|
||||
let tab_size = if needs_color {
|
||||
Some(0)
|
||||
} else {
|
||||
options
|
||||
.get_one::<String>(options::format::TAB_SIZE)
|
||||
.and_then(|size| size.parse::<usize>().ok())
|
||||
.or_else(|| std::env::var("TABSIZE").ok().and_then(|s| s.parse().ok()))
|
||||
} else {
|
||||
Some(0)
|
||||
}
|
||||
.unwrap_or(SPACES_IN_TAB);
|
||||
|
||||
|
||||
+10
-10
@@ -736,16 +736,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
.flatten()
|
||||
.cloned();
|
||||
|
||||
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 {
|
||||
if config.gnu_ext {
|
||||
input_files = {
|
||||
let mut files = files.collect::<Vec<_>>();
|
||||
if files.is_empty() {
|
||||
@@ -754,6 +745,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
files
|
||||
};
|
||||
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)?;
|
||||
|
||||
@@ -328,14 +328,14 @@ impl Formatter<&ExtendedBigDecimal> for Float {
|
||||
}
|
||||
|
||||
fn get_sign_indicator(sign: PositiveSign, negative: bool) -> String {
|
||||
if !negative {
|
||||
if negative {
|
||||
String::from("-")
|
||||
} else {
|
||||
match sign {
|
||||
PositiveSign::None => String::new(),
|
||||
PositiveSign::Plus => 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
|
||||
// parsing as a partial match.
|
||||
if !rest.is_empty() {
|
||||
if rest.is_empty() {
|
||||
ebd_result
|
||||
} else {
|
||||
Err(ExtendedParserError::PartialMatch(
|
||||
ebd_result.unwrap_or_else(|e| e.extract()),
|
||||
rest,
|
||||
))
|
||||
} else {
|
||||
ebd_result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user