Match cleanup (#2290)

This commit is contained in:
Joseph T. Lyons
2020-08-02 18:34:33 -04:00
committed by GitHub
parent f33da33626
commit c48ea46c4f
16 changed files with 102 additions and 152 deletions

View File

@ -352,14 +352,11 @@ pub fn swap_data_by_column_path(
let to_replace = to_replace?;
let replacement = callback(&to_replace)?;
match value.replace_data_at_column_path(&path, replacement) {
Some(replaced) => Ok(replaced),
None => Err(ShellError::labeled_error(
"missing column-path",
"missing column-path",
value.tag.span,
)),
}
value
.replace_data_at_column_path(&path, replacement)
.ok_or_else(|| {
ShellError::labeled_error("missing column-path", "missing column-path", value.tag.span)
})
}
pub fn insert_data_at_path(value: &Value, path: &str, new_value: Value) -> Option<Value> {