From ffbc0b0180d55861a2c846cbc80ad772373e4610 Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Mon, 27 Jun 2022 06:33:45 -0500 Subject: [PATCH] Header filtering out of for loop (#5896) * remove extra print * dataframe with real index * corrected dataframe tests * clippy error * clippy error * moved header filter out of loop --- crates/nu-command/src/viewers/table.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index a3811430ca..75e2c61d5a 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -364,6 +364,13 @@ fn convert_to_table( headers.insert(0, "#".into()); } + // The header with the INDEX is removed from the table headers since + // it is added to the natural table index + headers = headers + .into_iter() + .filter(|header| header != INDEX_COLUMN_NAME) + .collect(); + // Vec of Vec of String1, String2 where String1 is datatype and String2 is value let mut data: Vec> = Vec::new(); @@ -389,13 +396,6 @@ fn convert_to_table( row = vec![("string".to_string(), (row_val).to_string())]; } - // The header with the INDEX is removed from the table headers since - // it is added to the natural table index - headers = headers - .into_iter() - .filter(|header| header != INDEX_COLUMN_NAME) - .collect(); - if headers.is_empty() { row.push(( item.get_type().to_string(),