Use Record::get instead of Value functions#10925
Merged
sholderbach merged 6 commits intonushell:mainfrom Nov 8, 2023
Merged
Conversation
Record::get instead of Value cell path functionsRecord::get instead of Value functions
sholderbach
approved these changes
Nov 8, 2023
Member
sholderbach
left a comment
There was a problem hiding this comment.
Looking good!
Gotta watch out for potential merge conflicts but we should be moving along with the record stuff for this release
| } | ||
|
|
||
| fn fragment(input: Value, pretty: bool, config: &Config) -> String { | ||
| let headers = input.columns(); |
Member
There was a problem hiding this comment.
Good riddance Value::columns() is the weirdest method possible.
Comment on lines
+129
to
+142
| let group_key = if let Value::Record { val: row, .. } = row { | ||
| row.get(&column_name.item) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| match group_key { | ||
| Some(group_key) => Ok(group_key.as_string()?), | ||
| None => Err(ShellError::CantFindColumn { | ||
| col_name: column_name.item.to_string(), | ||
| span: column_name.span, | ||
| src_span: row.span(), | ||
| }), | ||
| } |
Member
There was a problem hiding this comment.
Great that this is like the only place where things get a tad less readable.
|
|
||
| let span = match label.get_data_by_key("span") { | ||
| Some(val @ Value::Record { .. }) => val, | ||
| let (span, span_span) = match label.get("span") { |
Member
There was a problem hiding this comment.
Yo I heard you like span so I put a span next to your span 😆
sholderbach
added a commit
that referenced
this pull request
Nov 8, 2023
# Description This is pretty complementary/orthogonal to @IanManske 's changes to `Value` cellpath accessors in: - #10925 - to a lesser extent #10926 ## Steps - Use `R.remove` in `Value.remove_data_at_cell_path` - Pretty sound after #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 (-)
hardfau1t
pushed a commit
to hardfau1t/nushell
that referenced
this pull request
Dec 14, 2023
# Description Where appropriate, this PR replaces instances of `Value::get_data_by_key` and `Value::follow_cell_path` with `Record::get`. This avoids some unnecessary clones and simplifies the code in some places.
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 Where appropriate, this PR replaces instances of `Value::get_data_by_key` and `Value::follow_cell_path` with `Record::get`. This avoids some unnecessary clones and simplifies the code in some places.
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 (-)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Where appropriate, this PR replaces instances of
Value::get_data_by_keyandValue::follow_cell_pathwithRecord::get. This avoids some unnecessary clones and simplifies the code in some places.