Use Record's public API in a bunch of places (#10927)

# Description
Since #10841 the goal is to remove the implementation details of
`Record` outside of core operations.

To this end use Record iterators and map-like accessors in a bunch of
places. In this PR I try to collect the boring cases where I don't
expect any dramatic performance impacts or don't have doubts about the
correctness afterwards

- Use checked record construction in `nu_plugin_example`
- Use `Record::into_iter` in `columns`
- Use `Record` iterators in `headers` cmd
- Use explicit record iterators in `split-by`
- Use `Record::into_iter` in variable completions
- Use `Record::values` iterator in `into sqlite`
- Use `Record::iter_mut` for-loop in `default`
- Change `nu_engine::nonexistent_column` to use iterator
- Use `Record::columns` iter in `nu-cmd-base`
- Use `Record::get_index` in `nu-command/network/http`
- Use `Record.insert()` in `merge`
- Refactor `move` to use encapsulated record API
- Use `Record.insert()` in `explore`
- Use proper `Record` API in `explore`
- Remove defensiveness around record in `explore`
- Use encapsulated record API in more `nu-command`s

# User-Facing Changes
None intentional

# Tests + Formatting
(-)
This commit is contained in:
Stefan Holderbach
2023-11-08 14:24:00 +01:00
committed by GitHub
parent b03ef56bcb
commit edbf3aaccb
24 changed files with 70 additions and 108 deletions

View File

@ -210,7 +210,7 @@ pub fn group_by(values: PipelineData, head: Span, config: &Config) -> (PipelineD
} = val
{
lists
.entry(record.cols.concat())
.entry(record.columns().map(|c| c.as_str()).collect::<String>())
.and_modify(|v: &mut Vec<Value>| v.push(val.clone()))
.or_insert_with(|| vec![val.clone()]);
} else {

View File

@ -209,7 +209,7 @@ pub fn value_to_string(
let mut row = vec![];
if let Value::Record { val, .. } = val {
for val in &val.vals {
for val in val.values() {
row.push(value_to_string_without_quotes(
val,
span,