difftreelog
feat add std.objectRemoveKey
in: master
Upstream issue: https://github.com/google/go-jsonnet/pull/686
2 files changed
crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -139,6 +139,7 @@
// Objects
("objectFieldsEx", builtin_object_fields_ex::INST),
("objectHasEx", builtin_object_has_ex::INST),
+ ("objectRemoveKey", builtin_object_remove_key::INST),
// Manifest
("escapeStringJson", builtin_escape_string_json::INST),
("manifestJsonEx", builtin_manifest_json_ex::INST),
crates/jrsonnet-stdlib/src/objects.rsdiffbeforeafterboth1use jrsonnet_evaluator::{1use jrsonnet_evaluator::{2 function::builtin,2 function::builtin,3 val::{StrValue, Val},3 val::{StrValue, Val},4 IStr, ObjValue,4 IStr, ObjValue, ObjValueBuilder,5};5};66728 obj.has_field_ex(fname, hidden)29 obj.has_field_ex(fname, hidden)29}30}3132#[builtin]33pub fn builtin_object_remove_key(obj: ObjValue, key: IStr) -> ObjValue {34 let mut new_obj = ObjValueBuilder::with_capacity(obj.len() - 1);35 for (k, v) in obj.iter() {36 if k == key {37 continue38 }39 new_obj.member(k).value_unchecked(v.unwrap())40 }4142 new_obj.build()43}3044