mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Remove Value::MatchPattern
(#11356)
# Description `Value::MatchPattern` implies that `MatchPattern`s are first-class values. This PR removes this case, and commands must now instead use `Expr::MatchPattern` to extract `MatchPattern`s just like how the `match` command does using `Expr::MatchBlock`. # User-Facing Changes Breaking API change for `nu_protocol` crate.
This commit is contained in:
@ -127,10 +127,7 @@ pub fn value_to_json_value(v: &Value) -> Result<nu_json::Value, ShellError> {
|
||||
|
||||
Value::List { vals, .. } => nu_json::Value::Array(json_list(vals)?),
|
||||
Value::Error { error, .. } => return Err(*error.clone()),
|
||||
Value::Closure { .. }
|
||||
| Value::Block { .. }
|
||||
| Value::Range { .. }
|
||||
| Value::MatchPattern { .. } => nu_json::Value::Null,
|
||||
Value::Closure { .. } | Value::Block { .. } | Value::Range { .. } => nu_json::Value::Null,
|
||||
Value::Binary { val, .. } => {
|
||||
nu_json::Value::Array(val.iter().map(|x| nu_json::Value::U64(*x as u64)).collect())
|
||||
}
|
||||
|
@ -241,12 +241,6 @@ pub fn value_to_string(
|
||||
))
|
||||
}
|
||||
}
|
||||
Value::MatchPattern { .. } => Err(ShellError::UnsupportedInput {
|
||||
msg: "match patterns are currently not nuon-compatible".to_string(),
|
||||
input: "value originates from here".into(),
|
||||
msg_span: span,
|
||||
input_span: v.span(),
|
||||
}),
|
||||
Value::Nothing { .. } => Ok("null".to_string()),
|
||||
Value::Range { val, .. } => Ok(format!(
|
||||
"{}..{}{}",
|
||||
|
@ -148,7 +148,6 @@ fn local_into_string(value: Value, separator: &str, config: &Config) -> String {
|
||||
Value::Binary { val, .. } => format!("{val:?}"),
|
||||
Value::CellPath { val, .. } => val.to_string(),
|
||||
Value::CustomValue { val, .. } => val.value_string(),
|
||||
Value::MatchPattern { val, .. } => format!("{:?}", val),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,6 @@ fn helper(engine_state: &EngineState, v: &Value) -> Result<toml::Value, ShellErr
|
||||
.collect::<Result<Vec<toml::Value>, ShellError>>()?,
|
||||
),
|
||||
Value::CustomValue { .. } => toml::Value::String("<Custom Value>".to_string()),
|
||||
Value::MatchPattern { .. } => toml::Value::String("<Match Pattern>".to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,6 @@ pub fn value_to_yaml_value(v: &Value) -> Result<serde_yaml::Value, ShellError> {
|
||||
.collect::<Result<Vec<serde_yaml::Value>, ShellError>>()?,
|
||||
),
|
||||
Value::CustomValue { .. } => serde_yaml::Value::Null,
|
||||
Value::MatchPattern { .. } => serde_yaml::Value::Null,
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user