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:
Ian Manske
2023-07-21 13:20:33 +00:00
committed by GitHub
parent 0b1e368cea
commit 7e1b922ea7
30 changed files with 413 additions and 216 deletions

View File

@ -85,8 +85,8 @@ impl SimpleCommand for TweakCmd {
fn parse_value(value: &str) -> Value {
match value {
"true" => Value::boolean(true, NuSpan::unknown()),
"false" => Value::boolean(false, NuSpan::unknown()),
"true" => Value::bool(true, NuSpan::unknown()),
"false" => Value::bool(false, NuSpan::unknown()),
s => Value::string(s.to_owned(), NuSpan::unknown()),
}
}

View File

@ -340,7 +340,7 @@ fn insert_bool(map: &mut HashMap<String, Value>, key: &str, value: bool) {
return;
}
map.insert(String::from(key), Value::boolean(value, Span::unknown()));
map.insert(String::from(key), Value::bool(value, Span::unknown()));
}
fn include_nu_config(config: &mut HashMap<String, Value>, style_computer: &StyleComputer) {