diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 8fc732852..5c74dc712 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -333,10 +333,9 @@ fn nl(reader: &mut BufReader, 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!( diff --git a/src/pathchk/pathchk.rs b/src/pathchk/pathchk.rs index 8159c24c9..f5534164c 100644 --- a/src/pathchk/pathchk.rs +++ b/src/pathchk/pathchk.rs @@ -86,11 +86,10 @@ pub fn uumain(args: Vec) -> 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 { diff --git a/src/printf/tokenize/unescaped_text.rs b/src/printf/tokenize/unescaped_text.rs index e21377368..ffb84ed50 100644 --- a/src/printf/tokenize/unescaped_text.rs +++ b/src/printf/tokenize/unescaped_text.rs @@ -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 diff --git a/src/readlink/readlink.rs b/src/readlink/readlink.rs index 460ea9643..170fff6d3 100644 --- a/src/readlink/readlink.rs +++ b/src/readlink/readlink.rs @@ -70,18 +70,13 @@ pub fn uumain(args: Vec) -> 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() {