mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
apply more clippy suggestions from nightly
This commit is contained in:
parent
07e9c5896c
commit
a4253d1254
7 changed files with 14 additions and 31 deletions
|
@ -116,7 +116,6 @@ struct Options {
|
||||||
show_listed_fs: bool,
|
show_listed_fs: bool,
|
||||||
show_fs_type: bool,
|
show_fs_type: bool,
|
||||||
show_inode_instead: bool,
|
show_inode_instead: bool,
|
||||||
print_grand_total: bool,
|
|
||||||
// block_size: usize,
|
// block_size: usize,
|
||||||
human_readable_base: i64,
|
human_readable_base: i64,
|
||||||
fs_selector: FsSelector,
|
fs_selector: FsSelector,
|
||||||
|
@ -286,7 +285,6 @@ impl Options {
|
||||||
show_listed_fs: false,
|
show_listed_fs: false,
|
||||||
show_fs_type: false,
|
show_fs_type: false,
|
||||||
show_inode_instead: false,
|
show_inode_instead: false,
|
||||||
print_grand_total: false,
|
|
||||||
// block_size: match env::var("BLOCKSIZE") {
|
// block_size: match env::var("BLOCKSIZE") {
|
||||||
// Ok(size) => size.parse().unwrap(),
|
// Ok(size) => size.parse().unwrap(),
|
||||||
// Err(_) => 512,
|
// Err(_) => 512,
|
||||||
|
@ -871,9 +869,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
if matches.is_present(OPT_ALL) {
|
if matches.is_present(OPT_ALL) {
|
||||||
opt.show_all_fs = true;
|
opt.show_all_fs = true;
|
||||||
}
|
}
|
||||||
if matches.is_present(OPT_TOTAL) {
|
|
||||||
opt.print_grand_total = true;
|
|
||||||
}
|
|
||||||
if matches.is_present(OPT_INODES) {
|
if matches.is_present(OPT_INODES) {
|
||||||
opt.show_inode_instead = true;
|
opt.show_inode_instead = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ fn detect_algo<'a>(
|
||||||
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<dyn Digest>, 512),
|
"sha512sum" => ("SHA512", Box::new(Sha512::new()) as Box<dyn Digest>, 512),
|
||||||
"b2sum" => ("BLAKE2", Box::new(Blake2b::new(64)) as Box<dyn Digest>, 512),
|
"b2sum" => ("BLAKE2", Box::new(Blake2b::new(64)) as Box<dyn Digest>, 512),
|
||||||
"sha3sum" => match matches.value_of("bits") {
|
"sha3sum" => match matches.value_of("bits") {
|
||||||
Some(bits_str) => match usize::from_str_radix(&bits_str, 10) {
|
Some(bits_str) => match (&bits_str).parse::<usize>() {
|
||||||
Ok(224) => (
|
Ok(224) => (
|
||||||
"SHA3-224",
|
"SHA3-224",
|
||||||
Box::new(Sha3_224::new()) as Box<dyn Digest>,
|
Box::new(Sha3_224::new()) as Box<dyn Digest>,
|
||||||
|
@ -128,7 +128,7 @@ fn detect_algo<'a>(
|
||||||
512,
|
512,
|
||||||
),
|
),
|
||||||
"shake128sum" => match matches.value_of("bits") {
|
"shake128sum" => match matches.value_of("bits") {
|
||||||
Some(bits_str) => match usize::from_str_radix(&bits_str, 10) {
|
Some(bits_str) => match (&bits_str).parse::<usize>() {
|
||||||
Ok(bits) => (
|
Ok(bits) => (
|
||||||
"SHAKE128",
|
"SHAKE128",
|
||||||
Box::new(Shake128::new()) as Box<dyn Digest>,
|
Box::new(Shake128::new()) as Box<dyn Digest>,
|
||||||
|
@ -139,7 +139,7 @@ fn detect_algo<'a>(
|
||||||
None => crash!(1, "--bits required for SHAKE-128"),
|
None => crash!(1, "--bits required for SHAKE-128"),
|
||||||
},
|
},
|
||||||
"shake256sum" => match matches.value_of("bits") {
|
"shake256sum" => match matches.value_of("bits") {
|
||||||
Some(bits_str) => match usize::from_str_radix(&bits_str, 10) {
|
Some(bits_str) => match (&bits_str).parse::<usize>() {
|
||||||
Ok(bits) => (
|
Ok(bits) => (
|
||||||
"SHAKE256",
|
"SHAKE256",
|
||||||
Box::new(Shake256::new()) as Box<dyn Digest>,
|
Box::new(Shake256::new()) as Box<dyn Digest>,
|
||||||
|
@ -182,7 +182,7 @@ fn detect_algo<'a>(
|
||||||
}
|
}
|
||||||
if matches.is_present("sha3") {
|
if matches.is_present("sha3") {
|
||||||
match matches.value_of("bits") {
|
match matches.value_of("bits") {
|
||||||
Some(bits_str) => match usize::from_str_radix(&bits_str, 10) {
|
Some(bits_str) => match (&bits_str).parse::<usize>() {
|
||||||
Ok(224) => set_or_crash(
|
Ok(224) => set_or_crash(
|
||||||
"SHA3-224",
|
"SHA3-224",
|
||||||
Box::new(Sha3_224::new()) as Box<dyn Digest>,
|
Box::new(Sha3_224::new()) as Box<dyn Digest>,
|
||||||
|
@ -226,7 +226,7 @@ fn detect_algo<'a>(
|
||||||
}
|
}
|
||||||
if matches.is_present("shake128") {
|
if matches.is_present("shake128") {
|
||||||
match matches.value_of("bits") {
|
match matches.value_of("bits") {
|
||||||
Some(bits_str) => match usize::from_str_radix(&bits_str, 10) {
|
Some(bits_str) => match (&bits_str).parse::<usize>() {
|
||||||
Ok(bits) => set_or_crash("SHAKE128", Box::new(Shake128::new()), bits),
|
Ok(bits) => set_or_crash("SHAKE128", Box::new(Shake128::new()), bits),
|
||||||
Err(err) => crash!(1, "{}", err),
|
Err(err) => crash!(1, "{}", err),
|
||||||
},
|
},
|
||||||
|
@ -235,7 +235,7 @@ fn detect_algo<'a>(
|
||||||
}
|
}
|
||||||
if matches.is_present("shake256") {
|
if matches.is_present("shake256") {
|
||||||
match matches.value_of("bits") {
|
match matches.value_of("bits") {
|
||||||
Some(bits_str) => match usize::from_str_radix(&bits_str, 10) {
|
Some(bits_str) => match (&bits_str).parse::<usize>() {
|
||||||
Ok(bits) => set_or_crash("SHAKE256", Box::new(Shake256::new()), bits),
|
Ok(bits) => set_or_crash("SHAKE256", Box::new(Shake256::new()), bits),
|
||||||
Err(err) => crash!(1, "{}", err),
|
Err(err) => crash!(1, "{}", err),
|
||||||
},
|
},
|
||||||
|
@ -253,7 +253,7 @@ fn detect_algo<'a>(
|
||||||
|
|
||||||
// TODO: return custom error type
|
// TODO: return custom error type
|
||||||
fn parse_bit_num(arg: &str) -> Result<usize, ParseIntError> {
|
fn parse_bit_num(arg: &str) -> Result<usize, ParseIntError> {
|
||||||
usize::from_str_radix(arg, 10)
|
arg.parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid_bit_num(arg: String) -> Result<(), String> {
|
fn is_valid_bit_num(arg: String) -> Result<(), String> {
|
||||||
|
|
|
@ -263,9 +263,5 @@ pub fn num_format(field: &FormatField, in_str_opt: Option<&String>) -> Option<St
|
||||||
};
|
};
|
||||||
// if we have a formatPrimitive, print its results
|
// if we have a formatPrimitive, print its results
|
||||||
// according to the field-char appropriate Formatter
|
// according to the field-char appropriate Formatter
|
||||||
if let Some(prim) = prim_opt {
|
prim_opt.map(|prim| fmtr.primitive_to_str(&prim, field.clone()))
|
||||||
Some(fmtr.primitive_to_str(&prim, field.clone()))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,14 +177,14 @@ fn get_config(matches: &clap::ArgMatches) -> Config {
|
||||||
}
|
}
|
||||||
if matches.is_present(options::WIDTH) {
|
if matches.is_present(options::WIDTH) {
|
||||||
let width_str = matches.value_of(options::WIDTH).expect(err_msg).to_string();
|
let width_str = matches.value_of(options::WIDTH).expect(err_msg).to_string();
|
||||||
config.line_width = crash_if_err!(1, usize::from_str_radix(&width_str, 10));
|
config.line_width = crash_if_err!(1, (&width_str).parse::<usize>());
|
||||||
}
|
}
|
||||||
if matches.is_present(options::GAP_SIZE) {
|
if matches.is_present(options::GAP_SIZE) {
|
||||||
let gap_str = matches
|
let gap_str = matches
|
||||||
.value_of(options::GAP_SIZE)
|
.value_of(options::GAP_SIZE)
|
||||||
.expect(err_msg)
|
.expect(err_msg)
|
||||||
.to_string();
|
.to_string();
|
||||||
config.gap_size = crash_if_err!(1, usize::from_str_radix(&gap_str, 10));
|
config.gap_size = crash_if_err!(1, (&gap_str).parse::<usize>());
|
||||||
}
|
}
|
||||||
if matches.is_present(options::FORMAT_ROFF) {
|
if matches.is_present(options::FORMAT_ROFF) {
|
||||||
config.format = OutFormat::Roff;
|
config.format = OutFormat::Roff;
|
||||||
|
|
|
@ -363,10 +363,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
|
|
||||||
let force = matches.is_present(options::FORCE);
|
let force = matches.is_present(options::FORCE);
|
||||||
let remove = matches.is_present(options::REMOVE);
|
let remove = matches.is_present(options::REMOVE);
|
||||||
let size_arg = match matches.value_of(options::SIZE) {
|
let size_arg = matches.value_of(options::SIZE).map(|s| s.to_string());
|
||||||
Some(s) => Some(s.to_string()),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
let size = get_size(size_arg);
|
let size = get_size(size_arg);
|
||||||
let exact = matches.is_present(options::EXACT) && size.is_none(); // if -s is given, ignore -x
|
let exact = matches.is_present(options::EXACT) && size.is_none(); // if -s is given, ignore -x
|
||||||
let zero = matches.is_present(options::ZERO);
|
let zero = matches.is_present(options::ZERO);
|
||||||
|
|
|
@ -149,10 +149,8 @@ fn next_tabstop(tabstops: &[usize], col: usize) -> Option<usize> {
|
||||||
Some(tabstops[0] - col % tabstops[0])
|
Some(tabstops[0] - col % tabstops[0])
|
||||||
} else {
|
} else {
|
||||||
// find next larger tab
|
// find next larger tab
|
||||||
match tabstops.iter().find(|&&t| t > col) {
|
// if there isn't one in the list, tab becomes a single space
|
||||||
Some(t) => Some(t - col),
|
tabstops.iter().find(|&&t| t > col).map(|t| t-col)
|
||||||
None => None, // if there isn't one in the list, tab becomes a single space
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
need_runlevel,
|
need_runlevel,
|
||||||
need_users,
|
need_users,
|
||||||
my_line_only,
|
my_line_only,
|
||||||
has_records: false,
|
|
||||||
args: matches.free,
|
args: matches.free,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -247,7 +246,6 @@ struct Who {
|
||||||
need_runlevel: bool,
|
need_runlevel: bool,
|
||||||
need_users: bool,
|
need_users: bool,
|
||||||
my_line_only: bool,
|
my_line_only: bool,
|
||||||
has_records: bool,
|
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,8 +319,7 @@ impl Who {
|
||||||
println!("{}", users.join(" "));
|
println!("{}", users.join(" "));
|
||||||
println!("# users={}", users.len());
|
println!("# users={}", users.len());
|
||||||
} else {
|
} else {
|
||||||
let mut records = Utmpx::iter_all_records().read_from(f).peekable();
|
let records = Utmpx::iter_all_records().read_from(f).peekable();
|
||||||
self.has_records = records.peek().is_some();
|
|
||||||
|
|
||||||
if self.include_heading {
|
if self.include_heading {
|
||||||
self.print_heading()
|
self.print_heading()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue