mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +00:00
refactor/polish ~ fix cargo clippy
complaints (default/tests => let ... = if ...
)
This commit is contained in:
parent
d192ebea5b
commit
8142ecf325
4 changed files with 16 additions and 24 deletions
|
@ -333,10 +333,9 @@ fn nl<T: Read>(reader: &mut BufReader<T>, settings: &Settings) {
|
|||
// way, start counting empties from zero once more.
|
||||
empty_line_count = 0;
|
||||
// A line number is to be printed.
|
||||
let mut w: usize = 0;
|
||||
if settings.number_width > line_no_width {
|
||||
w = settings.number_width - line_no_width;
|
||||
}
|
||||
let w = if settings.number_width > line_no_width {
|
||||
settings.number_width - line_no_width
|
||||
} else { 0 };
|
||||
let fill: String = repeat(fill_char).take(w).collect();
|
||||
match settings.number_format {
|
||||
NumberFormat::Left => println!(
|
||||
|
|
|
@ -86,11 +86,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
0
|
||||
}
|
||||
_ => {
|
||||
let mut res = true;
|
||||
if matches.free.len() == 0 {
|
||||
let mut res = if matches.free.is_empty() {
|
||||
show_error!("missing operand\nTry {} --help for more information", NAME);
|
||||
res = false;
|
||||
}
|
||||
false
|
||||
} else { true };
|
||||
// free strings are path operands
|
||||
// FIXME: TCS, seems inefficient and overly verbose (?)
|
||||
for p in matches.free {
|
||||
|
|
|
@ -60,11 +60,10 @@ impl UnescapedText {
|
|||
// dropped-in as a replacement.
|
||||
fn validate_iec(val: u32, eight_word: bool) {
|
||||
let mut preface = 'u';
|
||||
let mut leading_zeros = 4;
|
||||
if eight_word {
|
||||
let leading_zeros = if eight_word {
|
||||
preface = 'U';
|
||||
leading_zeros = 8;
|
||||
}
|
||||
8
|
||||
} else { 4 };
|
||||
let err_msg = format!(
|
||||
"invalid universal character name {0}{1:02$x}",
|
||||
preface, val, leading_zeros
|
||||
|
|
|
@ -70,18 +70,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
let silent = matches.opt_present("silent") || matches.opt_present("quiet");
|
||||
let verbose = matches.opt_present("verbose");
|
||||
|
||||
let mut can_mode = CanonicalizeMode::None;
|
||||
if matches.opt_present("canonicalize") {
|
||||
can_mode = CanonicalizeMode::Normal;
|
||||
}
|
||||
|
||||
if matches.opt_present("canonicalize-existing") {
|
||||
can_mode = CanonicalizeMode::Existing;
|
||||
}
|
||||
|
||||
if matches.opt_present("canonicalize-missing") {
|
||||
can_mode = CanonicalizeMode::Missing;
|
||||
}
|
||||
let can_mode = if matches.opt_present("canonicalize") {
|
||||
CanonicalizeMode::Normal
|
||||
} else if matches.opt_present("canonicalize-existing") {
|
||||
CanonicalizeMode::Existing
|
||||
} else if matches.opt_present("canonicalize-missing") {
|
||||
CanonicalizeMode::Missing
|
||||
} else { CanonicalizeMode::None };
|
||||
|
||||
let files = matches.free;
|
||||
if files.is_empty() {
|
||||
|
|
Loading…
Reference in a new issue