Skip to content

Use record API in more parts of nu-protocol#10928

Merged
sholderbach merged 6 commits intonushell:mainfrom
sholderbach:record-protocol-steps
Nov 8, 2023
Merged

Use record API in more parts of nu-protocol#10928
sholderbach merged 6 commits intonushell:mainfrom
sholderbach:record-protocol-steps

Conversation

@sholderbach
Copy link
Copy Markdown
Member

Description

This is pretty complementary/orthogonal to @IanManske 's changes to Value cellpath accessors in:

Steps

  • Use R.remove in Value.remove_data_at_cell_path
  • Update did_you_mean helper to use iterator
  • Change Value::columns to return iterator
    • This is not a place of honor
  • Use Record::get in Value::get_data_by_key

User-Facing Changes

None intentional, potential edge cases on duplicated columns could change (considered undefined behavior)

Tests + Formatting

(-)

This breaks two tests

Using `Record::remove` assumes that the keys are all unique. The current
implementation since nushell#8446 uses the less efficient way of going over the
whole record with `.retain` to deal with repeated keys.

Culprit in the example is the table literal
This is required if `Record` only exposes a `Columns` iterator.

This helper is only lightly used. Dealing with the non `Value::Record`
case is a bit ugly, with the `impl Iterator` erasure some optimizations
like `DoubleEndedIterator`/`TrustedLen` become unavailable.

For now cloned in a few places.
@sholderbach sholderbach merged commit 92503e6 into nushell:main Nov 8, 2023
@sholderbach sholderbach deleted the record-protocol-steps branch November 8, 2023 22:03
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
# Description

This is pretty complementary/orthogonal to @IanManske 's changes to
`Value` cellpath accessors in:
- nushell#10925
- to a lesser extent nushell#10926

## Steps
- Use `R.remove` in `Value.remove_data_at_cell_path`
- Pretty sound after nushell#10875 (tests mentioned in commit message have been
removed by that)
- Update `did_you_mean` helper to use iterator
- Change `Value::columns` to return iterator
  - This is not a place of honor
- Use `Record::get` in `Value::get_data_by_key`
# User-Facing Changes
None intentional, potential edge cases on duplicated columns could
change (considered undefined behavior)

# Tests + Formatting
(-)
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
# Description

This is pretty complementary/orthogonal to @IanManske 's changes to
`Value` cellpath accessors in:
- nushell#10925
- to a lesser extent nushell#10926

## Steps
- Use `R.remove` in `Value.remove_data_at_cell_path`
- Pretty sound after nushell#10875 (tests mentioned in commit message have been
removed by that)
- Update `did_you_mean` helper to use iterator
- Change `Value::columns` to return iterator
  - This is not a place of honor
- Use `Record::get` in `Value::get_data_by_key`
# User-Facing Changes
None intentional, potential edge cases on duplicated columns could
change (considered undefined behavior)

# Tests + Formatting
(-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant