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.rsdiffbeforeafterboth139 // Objects139 // Objects140 ("objectFieldsEx", builtin_object_fields_ex::INST),140 ("objectFieldsEx", builtin_object_fields_ex::INST),141 ("objectHasEx", builtin_object_has_ex::INST),141 ("objectHasEx", builtin_object_has_ex::INST),142 ("objectRemoveKey", builtin_object_remove_key::INST),142 // Manifest143 // Manifest143 ("escapeStringJson", builtin_escape_string_json::INST),144 ("escapeStringJson", builtin_escape_string_json::INST),144 ("manifestJsonEx", builtin_manifest_json_ex::INST),145 ("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