From dbcea393cfba08b4ffe3b6b6d0acd364a59cb342 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 29 Apr 2023 09:06:21 -0400 Subject: [PATCH] `excel`: use more readable, efficient extend_from_slice --- src/cmd/excel.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/cmd/excel.rs b/src/cmd/excel.rs index 02ec80848..04b4f67b4 100644 --- a/src/cmd/excel.rs +++ b/src/cmd/excel.rs @@ -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)?;