use nu_protocol::Value; use std::collections::HashSet; pub fn get_columns<'a>(input: impl IntoIterator) -> Vec { let mut columns = vec![]; for item in input { if let Value::Record { cols, .. } = item { for col in cols { if !columns.contains(col) { columns.push(col.to_string()); } } } else { return vec![]; } } columns } // If a column doesn't exist in the input, return it. pub fn nonexistent_column(inputs: Vec, columns: Vec) -> Option { let set: HashSet = HashSet::from_iter(columns.iter().cloned()); for input in &inputs { if set.contains(input) { continue; } return Some(input.clone()); } None }