mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
remove explicit iter loops
This commit is contained in:
parent
cf24620d3d
commit
2f85610cc3
13 changed files with 17 additions and 17 deletions
|
@ -741,7 +741,7 @@ fn parse_path_args(path_args: &[String], options: &Options) -> CopyResult<(Vec<S
|
||||||
};
|
};
|
||||||
|
|
||||||
if options.strip_trailing_slashes {
|
if options.strip_trailing_slashes {
|
||||||
for source in paths.iter_mut() {
|
for source in &mut paths {
|
||||||
*source = source.components().as_path().to_owned();
|
*source = source.components().as_path().to_owned();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,7 +646,7 @@ fn conv_block_unblock_helper<R: Read>(
|
||||||
let mut blocks = block(&buf, cbs, rstat);
|
let mut blocks = block(&buf, cbs, rstat);
|
||||||
|
|
||||||
if let Some(ct) = i.cflags.ctable {
|
if let Some(ct) = i.cflags.ctable {
|
||||||
for buf in blocks.iter_mut() {
|
for buf in &mut blocks {
|
||||||
apply_conversion(buf, ct);
|
apply_conversion(buf, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,7 +367,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
for fs in fs_list.iter() {
|
for fs in &fs_list {
|
||||||
print!("{0: <16} ", fs.mount_info.dev_name);
|
print!("{0: <16} ", fs.mount_info.dev_name);
|
||||||
if opt.show_fs_type {
|
if opt.show_fs_type {
|
||||||
print!("{0: <5} ", fs.mount_info.fs_type);
|
print!("{0: <5} ", fs.mount_info.fs_type);
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if !dirnames.is_empty() {
|
if !dirnames.is_empty() {
|
||||||
for path in dirnames.iter() {
|
for path in &dirnames {
|
||||||
let p = Path::new(path);
|
let p = Path::new(path);
|
||||||
match p.parent() {
|
match p.parent() {
|
||||||
Some(d) => {
|
Some(d) => {
|
||||||
|
|
|
@ -853,7 +853,7 @@ mod test_du {
|
||||||
(Some("K".to_string()), 1024),
|
(Some("K".to_string()), 1024),
|
||||||
(None, 1024),
|
(None, 1024),
|
||||||
];
|
];
|
||||||
for it in test_data.iter() {
|
for it in &test_data {
|
||||||
assert_eq!(read_block_size(it.0.as_deref()), it.1);
|
assert_eq!(read_block_size(it.0.as_deref()), it.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ fn expand(options: &Options) -> std::io::Result<()> {
|
||||||
let ts = options.tabstops.as_ref();
|
let ts = options.tabstops.as_ref();
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
||||||
for file in options.files.iter() {
|
for file in &options.files {
|
||||||
let mut fh = open(file);
|
let mut fh = open(file);
|
||||||
|
|
||||||
while match fh.read_until(b'\n', &mut buf) {
|
while match fh.read_until(b'\n', &mut buf) {
|
||||||
|
|
|
@ -1007,7 +1007,7 @@ fn mpr(paths: &[String], options: &OutputOptions) -> Result<i32, PrError> {
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
let mut page_counter = start_page;
|
let mut page_counter = start_page;
|
||||||
|
|
||||||
for (_key, file_line_group) in file_line_groups.into_iter() {
|
for (_key, file_line_group) in &file_line_groups {
|
||||||
for file_line in file_line_group {
|
for file_line in file_line_group {
|
||||||
if let Err(e) = file_line.line_content {
|
if let Err(e) = file_line.line_content {
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
|
|
|
@ -571,7 +571,7 @@ impl<'a> Line<'a> {
|
||||||
|
|
||||||
let mut fields = vec![];
|
let mut fields = vec![];
|
||||||
tokenize(self.line, settings.separator, &mut fields);
|
tokenize(self.line, settings.separator, &mut fields);
|
||||||
for selector in settings.selectors.iter() {
|
for selector in &settings.selectors {
|
||||||
let mut selection = selector.get_range(self.line, Some(&fields));
|
let mut selection = selector.get_range(self.line, Some(&fields));
|
||||||
match selector.settings.mode {
|
match selector.settings.mode {
|
||||||
SortMode::Numeric | SortMode::HumanNumeric => {
|
SortMode::Numeric | SortMode::HumanNumeric => {
|
||||||
|
|
|
@ -249,7 +249,7 @@ fn unexpand(options: &Options) -> std::io::Result<()> {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
let lastcol = if ts.len() > 1 { *ts.last().unwrap() } else { 0 };
|
let lastcol = if ts.len() > 1 { *ts.last().unwrap() } else { 0 };
|
||||||
|
|
||||||
for file in options.files.iter() {
|
for file in &options.files {
|
||||||
let mut fh = open(file);
|
let mut fh = open(file);
|
||||||
|
|
||||||
while match fh.read_until(b'\n', &mut buf) {
|
while match fh.read_until(b'\n', &mut buf) {
|
||||||
|
|
|
@ -500,7 +500,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_normalize_path() {
|
fn test_normalize_path() {
|
||||||
for test in NORMALIZE_PATH_TESTS.iter() {
|
for test in &NORMALIZE_PATH_TESTS {
|
||||||
let path = Path::new(test.path);
|
let path = Path::new(test.path);
|
||||||
let normalized = normalize_path(path);
|
let normalized = normalize_path(path);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl Memo {
|
||||||
pm
|
pm
|
||||||
}
|
}
|
||||||
pub fn apply(&self, pf_args_it: &mut Peekable<Iter<String>>) {
|
pub fn apply(&self, pf_args_it: &mut Peekable<Iter<String>>) {
|
||||||
for tkn in self.tokens.iter() {
|
for tkn in &self.tokens {
|
||||||
tkn.print(pf_args_it);
|
tkn.print(pf_args_it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ fn test_relpath_with_from_no_d() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
for test in TESTS.iter() {
|
for test in &TESTS {
|
||||||
let from: &str = &convert_path(test.from);
|
let from: &str = &convert_path(test.from);
|
||||||
let to: &str = &convert_path(test.to);
|
let to: &str = &convert_path(test.to);
|
||||||
let expected: &str = &convert_path(test.expected);
|
let expected: &str = &convert_path(test.expected);
|
||||||
|
@ -96,7 +96,7 @@ fn test_relpath_with_from_with_d() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
for test in TESTS.iter() {
|
for test in &TESTS {
|
||||||
let from: &str = &convert_path(test.from);
|
let from: &str = &convert_path(test.from);
|
||||||
let to: &str = &convert_path(test.to);
|
let to: &str = &convert_path(test.to);
|
||||||
let pwd = at.as_string();
|
let pwd = at.as_string();
|
||||||
|
@ -132,7 +132,7 @@ fn test_relpath_no_from_no_d() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
for test in TESTS.iter() {
|
for test in &TESTS {
|
||||||
let to: &str = &convert_path(test.to);
|
let to: &str = &convert_path(test.to);
|
||||||
at.mkdir_all(to);
|
at.mkdir_all(to);
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ fn test_relpath_no_from_with_d() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
for test in TESTS.iter() {
|
for test in &TESTS {
|
||||||
let to: &str = &convert_path(test.to);
|
let to: &str = &convert_path(test.to);
|
||||||
let pwd = at.as_string();
|
let pwd = at.as_string();
|
||||||
at.mkdir_all(to);
|
at.mkdir_all(to);
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn test_tee_processing_multiple_operands() {
|
||||||
// POSIX says: "Processing of at least 13 file operands shall be supported."
|
// POSIX says: "Processing of at least 13 file operands shall be supported."
|
||||||
|
|
||||||
let content = "tee_sample_content";
|
let content = "tee_sample_content";
|
||||||
for &n in [1, 2, 12, 13].iter() {
|
for &n in &[1, 2, 12, 13] {
|
||||||
let files = (1..=n).map(|x| x.to_string()).collect::<Vec<_>>();
|
let files = (1..=n).map(|x| x.to_string()).collect::<Vec<_>>();
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ fn test_tee_processing_multiple_operands() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is(content);
|
.stdout_is(content);
|
||||||
|
|
||||||
for file in files.iter() {
|
for file in &files {
|
||||||
assert!(at.file_exists(file));
|
assert!(at.file_exists(file));
|
||||||
assert_eq!(at.read(file), content);
|
assert_eq!(at.read(file), content);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue