From 79a44d768cecc9bff751d4772cc3faf2906920eb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 25 Aug 2023 15:29:15 +0200 Subject: [PATCH] uucore,comm: fix warnings from bool_to_int_with_if --- src/uu/comm/src/comm.rs | 12 ++---------- src/uucore/src/lib/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 1bb0020d5..e6977142e 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -30,14 +30,6 @@ mod options { pub const ZERO_TERMINATED: &str = "zero-terminated"; } -fn column_width(col: &str, opts: &ArgMatches) -> usize { - if opts.get_flag(col) { - 0 - } else { - 1 - } -} - enum Input { Stdin(Stdin), FileIn(BufReader), @@ -75,8 +67,8 @@ fn comm(a: &mut LineReader, b: &mut LineReader, opts: &ArgMatches) { delim => delim, }; - let width_col_1 = column_width(options::COLUMN_1, opts); - let width_col_2 = column_width(options::COLUMN_2, opts); + let width_col_1 = usize::from(!opts.get_flag(options::COLUMN_1)); + let width_col_2 = usize::from(!opts.get_flag(options::COLUMN_2)); let delim_col_2 = delim.repeat(width_col_1); let delim_col_3 = delim.repeat(width_col_1 + width_col_2); diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 1d97522c7..add5d9d3b 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -133,8 +133,8 @@ pub fn set_utility_is_second_arg() { static ARGV: Lazy> = Lazy::new(|| wild::args_os().collect()); static UTIL_NAME: Lazy = Lazy::new(|| { - let base_index = if get_utility_is_second_arg() { 1 } else { 0 }; - let is_man = if ARGV[base_index].eq("manpage") { 1 } else { 0 }; + let base_index = usize::from(get_utility_is_second_arg()); + let is_man = usize::from(ARGV[base_index].eq("manpage")); let argv_index = base_index + is_man; ARGV[argv_index].to_string_lossy().into_owned()