mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 15:36:17 +02:00
Add functions for each Value
case (#9736)
# Description This PR ensures functions exist to extract and create each and every `Value` case. It also renames `Value::boolean` to `Value::bool` to match `Value::test_bool`, `Value::as_bool`, and `Value::Bool`. Similarly, `Value::as_integer` was renamed to `Value::as_int` to be consistent with `Value::int`, `Value::test_int`, and `Value::Int`. These two renames can be undone if necessary. # User-Facing Changes No user facing changes, but two public functions were renamed which may affect downstream dependents.
This commit is contained in:
@@ -59,27 +59,27 @@ impl Command for SubCommand {
|
||||
vals: vec![
|
||||
Value::Record {
|
||||
cols: vec!["value".to_string()],
|
||||
vals: vec![Value::boolean(false, span)],
|
||||
vals: vec![Value::bool(false, span)],
|
||||
span,
|
||||
},
|
||||
Value::Record {
|
||||
cols: vec!["value".to_string()],
|
||||
vals: vec![Value::boolean(true, span)],
|
||||
vals: vec![Value::bool(true, span)],
|
||||
span,
|
||||
},
|
||||
Value::Record {
|
||||
cols: vec!["value".to_string()],
|
||||
vals: vec![Value::boolean(false, span)],
|
||||
vals: vec![Value::bool(false, span)],
|
||||
span,
|
||||
},
|
||||
Value::Record {
|
||||
cols: vec!["value".to_string()],
|
||||
vals: vec![Value::boolean(true, span)],
|
||||
vals: vec![Value::bool(true, span)],
|
||||
span,
|
||||
},
|
||||
Value::Record {
|
||||
cols: vec!["value".to_string()],
|
||||
vals: vec![Value::boolean(true, span)],
|
||||
vals: vec![Value::bool(true, span)],
|
||||
span,
|
||||
},
|
||||
],
|
||||
@@ -89,27 +89,27 @@ impl Command for SubCommand {
|
||||
Example {
|
||||
description: "Convert bool to boolean",
|
||||
example: "true | into bool",
|
||||
result: Some(Value::boolean(true, span)),
|
||||
result: Some(Value::bool(true, span)),
|
||||
},
|
||||
Example {
|
||||
description: "convert integer to boolean",
|
||||
example: "1 | into bool",
|
||||
result: Some(Value::boolean(true, span)),
|
||||
result: Some(Value::bool(true, span)),
|
||||
},
|
||||
Example {
|
||||
description: "convert decimal to boolean",
|
||||
example: "0.3 | into bool",
|
||||
result: Some(Value::boolean(true, span)),
|
||||
result: Some(Value::bool(true, span)),
|
||||
},
|
||||
Example {
|
||||
description: "convert decimal string to boolean",
|
||||
example: "'0.0' | into bool",
|
||||
result: Some(Value::boolean(false, span)),
|
||||
result: Some(Value::bool(false, span)),
|
||||
},
|
||||
Example {
|
||||
description: "convert string to boolean",
|
||||
example: "'true' | into bool",
|
||||
result: Some(Value::boolean(true, span)),
|
||||
result: Some(Value::bool(true, span)),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ impl Command for SubCommand {
|
||||
example: "[[value]; [false]] | into record",
|
||||
result: Some(Value::Record {
|
||||
cols: vec!["value".to_string()],
|
||||
vals: vec![Value::boolean(false, span)],
|
||||
vals: vec![Value::bool(false, span)],
|
||||
span,
|
||||
}),
|
||||
},
|
||||
|
Reference in New Issue
Block a user