forked from extern/nushell
Convert more examples and tests to record!
macro (#10840)
# Description Use `record!` macro instead of defining two separate `vec!` for `cols` and `vals` when appropriate. This visually aligns the key with the value. Further more you don't have to deal with the construction of `Record { cols, vals }` so we can hide the implementation details in the future. ## State Not covering all possible commands yet, also some tests/examples are better expressed by creating cols and vals separately. # User/Developer-Facing Changes The examples and tests should read more natural. No relevant functional change # Bycatch Where I noticed it I replaced usage of `Value` constructors with `Span::test_data()` or `Span::unknown()` to the `Value::test_...` constructors. This should make things more readable and also simplify changes to the `Span` system in the future.
This commit is contained in:
committed by
GitHub
parent
7d67ca3652
commit
4b301710d3
@ -3,7 +3,7 @@ use crate::math::utils::run_with_function;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, Record, ShellError, Signature, Span, Type, Value,
|
||||
record, Category, Example, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -52,9 +52,9 @@ impl Command for SubCommand {
|
||||
Example {
|
||||
description: "Compute the minima of the columns of a table",
|
||||
example: "[{a: 1 b: 3} {a: 2 b: -1}] | math min",
|
||||
result: Some(Value::test_record(Record {
|
||||
cols: vec!["a".to_string(), "b".to_string()],
|
||||
vals: vec![Value::test_int(1), Value::test_int(-1)],
|
||||
result: Some(Value::test_record(record! {
|
||||
"a" => Value::test_int(1),
|
||||
"b" => Value::test_int(-1),
|
||||
})),
|
||||
},
|
||||
Example {
|
||||
|
Reference in New Issue
Block a user