1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

fix more clippy warnings

This commit is contained in:
DevSabb 2022-03-28 11:09:26 -04:00
parent 16ad4bc069
commit 68b1f04f7d
2 changed files with 10 additions and 12 deletions

View file

@ -7,7 +7,7 @@
// spell-checker:ignore (ToDO) cmdline evec seps rvec fdata
use clap::{crate_version, Arg, Command};
use clap::{crate_version, Arg, Command, Values};
use rand::prelude::SliceRandom;
use rand::RngCore;
use std::fs::File;
@ -76,11 +76,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let options = Options {
head_count: {
let headcounts: Vec<&str> = matches
.values_of(options::HEAD_COUNT)
.unwrap_or_default()
.collect();
match parse_head_count(&headcounts) {
let mut headcounts: Values<'_> =
matches.values_of(options::HEAD_COUNT).unwrap_or_default();
match parse_head_count(&mut headcounts) {
Ok(val) => val,
Err(msg) => return Err(USimpleError::new(1, msg)),
}
@ -298,7 +296,7 @@ fn parse_range(input_range: &str) -> Result<(usize, usize), String> {
}
}
fn parse_head_count(headcounts: &[&str]) -> Result<usize, String> {
fn parse_head_count(headcounts: &mut Values<'_>) -> Result<usize, String> {
let mut result = std::usize::MAX;
for count in headcounts {
match count.parse::<usize>() {

View file

@ -202,11 +202,11 @@ fn test_shuf_multiple_input_line_count() {
let result = new_ucmd!()
.args(&["-i10-200", "-n", "10", "-n", "5"])
.succeeds();
result.no_stderr();
let result_seq: Vec<&str> = result
result.no_stderr();
let result_seq = result
.stdout_str()
.split('\n')
.filter(|x| !x.is_empty())
.collect();
assert_eq!(result_seq.len(), 5, "Output should have 5 items");
.filter(|x| !x.is_empty());
assert_eq!(result_seq.count(), 5, "Output should have 5 items");
}