From 8fae48fb5410867e584ea52da15cab41ec65667f Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:44:40 -0500 Subject: [PATCH] chore: apply clippy suggestions warning: usage of `FromIterator::from_iter` --> src/cmd/stats.rs:789:27 | 789 | work_br = csv::ByteRecord::from_iter(vec![&*header].into_iter().chain(stat)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `vec![&*header].into_iter().chain(stat).collect::>()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect = note: `-W clippy::from-iter-instead-of-collect` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::from_iter_instead_of_collect)]` warning: implicitly cloning a `ByteRecord` by calling `to_owned` on its dereferenced type --> src/cmd/stats.rs:803:31 | 803 | stats_br_vec.push(dataset_stats_br.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `dataset_stats_br.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone = note: `-W clippy::implicit-clone` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::implicit_clone)]` warning: implicitly cloning a `ByteRecord` by calling `to_owned` on its dereferenced type --> src/cmd/stats.rs:812:31 | 812 | stats_br_vec.push(dataset_stats_br.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `dataset_stats_br.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone warning: implicitly cloning a `ByteRecord` by calling `to_owned` on its dereferenced type --> src/cmd/stats.rs:825:31 | 825 | stats_br_vec.push(dataset_stats_br.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `dataset_stats_br.clone()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone --- src/cmd/stats.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cmd/stats.rs b/src/cmd/stats.rs index 7eecfdf73..a84e84712 100644 --- a/src/cmd/stats.rs +++ b/src/cmd/stats.rs @@ -786,7 +786,10 @@ pub fn run(argv: &[&str]) -> CliResult<()> { header.to_vec() }; let stat = stat.iter().map(str::as_bytes); - work_br = csv::ByteRecord::from_iter(vec![&*header].into_iter().chain(stat)); + work_br = vec![&*header] + .into_iter() + .chain(stat) + .collect::(); wtr.write_record(&work_br)?; stats_br_vec.push(work_br); } @@ -800,7 +803,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { } dataset_stats_br.push_field(itoa::Buffer::new().format(*record_count).as_bytes()); wtr.write_record(&dataset_stats_br)?; - stats_br_vec.push(dataset_stats_br.to_owned()); + stats_br_vec.push(dataset_stats_br.clone()); dataset_stats_br.clear(); dataset_stats_br.push_field(b"_qsv_columncount"); @@ -809,7 +812,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { } dataset_stats_br.push_field(itoa::Buffer::new().format(headers.len()).as_bytes()); wtr.write_record(&dataset_stats_br)?; - stats_br_vec.push(dataset_stats_br.to_owned()); + stats_br_vec.push(dataset_stats_br.clone()); dataset_stats_br.clear(); dataset_stats_br.push_field(b"_qsv_filesize_bytes"); @@ -822,7 +825,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> { .as_bytes(), ); wtr.write_record(&dataset_stats_br)?; - stats_br_vec.push(dataset_stats_br.to_owned()); + stats_br_vec.push(dataset_stats_br.clone()); // compute the hash using stats, instead of scanning the entire file // so the performance is constant regardless of file size