diff --git a/crates/nu-command/src/viewers/griddle.rs b/crates/nu-command/src/viewers/griddle.rs index 4daa0dcbf7..7b1a2e2ce5 100644 --- a/crates/nu-command/src/viewers/griddle.rs +++ b/crates/nu-command/src/viewers/griddle.rs @@ -261,7 +261,7 @@ fn convert_to_list( let mut iter = iter.into_iter().peekable(); if let Some(first) = iter.peek() { - let mut headers = first.columns(); + let mut headers = first.columns().to_vec(); if !headers.is_empty() { headers.insert(0, "#".into()); diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 69a486707a..81d5177322 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -1732,10 +1732,10 @@ impl Value { matches!(self, Value::Bool { val: false, .. }) } - pub fn columns(&self) -> Vec { + pub fn columns(&self) -> &[String] { match self { - Value::Record { cols, .. } => cols.clone(), - _ => vec![], + Value::Record { cols, .. } => cols, + _ => &[], } }