Skip to content

Commit

Permalink
excel: use more readable, efficient extend_from_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Apr 29, 2023
1 parent f2908ce commit dbcea39
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/cmd/excel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,20 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}
match metadata_mode {
MetadataMode::Csv => {
record.push_field("index");
record.push_field("sheet_name");
record.push_field("headers");
record.push_field("num_columns");
record.push_field("num_rows");
record.push_field("safe_headers");
record.push_field("safe_headers_count");
record.push_field("unsafe_headers");
record.push_field("unsafe_headers_count");
record.push_field("duplicate_headers_count");
let mut metadata_fields = Vec::with_capacity(10);
metadata_fields.extend_from_slice(&[
"index",
"sheet_name",
"headers",
"num_columns",
"num_rows",
"safe_headers",
"safe_headers_count",
"unsafe_headers",
"unsafe_headers_count",
"duplicate_headers_count",
]);
record = csv::StringRecord::from(metadata_fields);

wtr.write_record(&record)?;

Expand Down

0 comments on commit dbcea39

Please sign in to comment.