Flatten should flatten embedded table (#534)

This commit is contained in:
JT
2021-12-21 06:03:18 +11:00
committed by GitHub
parent caf73c36f2
commit 152467a858
4 changed files with 52 additions and 14 deletions

View File

@ -195,6 +195,17 @@ impl Value {
}
}
pub fn as_list(&self) -> Result<&[Value], ShellError> {
match self {
Value::List { vals, .. } => Ok(vals),
x => Err(ShellError::CantConvert(
"list".into(),
x.get_type().to_string(),
self.span()?,
)),
}
}
pub fn as_bool(&self) -> Result<bool, ShellError> {
match self {
Value::Bool { val, .. } => Ok(*val),