Skip to content

Commit

Permalink
chore: apply clippy suggestions
Browse files Browse the repository at this point in the history
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::<csv::ByteRecord<_>>()`
    |
    = 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
  • Loading branch information
jqnatividad committed Nov 18, 2024
1 parent 6ca0100 commit 8fae48f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cmd/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<csv::ByteRecord>();
wtr.write_record(&work_br)?;
stats_br_vec.push(work_br);
}
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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
Expand Down

0 comments on commit 8fae48f

Please sign in to comment.