git.delta.rocks / jrsonnet / refs/commits / bf30e8108f64

difftreelog

fix ObjValue is_empty should not account hidden fields

Yaroslav Bolyukin2024-06-18parent: #cc55b2d.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
669 }669 }
670670
671 fn len(&self) -> usize {671 fn len(&self) -> usize {
672 // Maybe it will be better to not compute sort key here?
672 self.fields_visibility()673 self.fields_visibility()
673 .into_iter()674 .into_iter()
674 .filter(|(_, (visible, _))| *visible)675 .filter(|(_, (visible, _))| *visible)
675 .count()676 .count()
676 }677 }
677678
679 /// Returns false only if there is any visible entry.
680 ///
681 /// Note that object with hidden fields `{a:: 1}` will be reported as empty here.
678 fn is_empty(&self) -> bool {682 fn is_empty(&self) -> bool {
679 if !self.this_entries.is_empty() {
680 return false;
681 }
682 self.sup.as_ref().map_or(true, ObjValue::is_empty)683 self.len() != 0
683 }684 }
684685
685 /// Run callback for every field found in object686 /// Run callback for every field found in object
modifiedcrates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth
28}28}
2929
30#[builtin]30#[builtin]
31pub fn builtin_escape_string_bash(str: String) -> String {31pub fn builtin_escape_string_bash(str_: String) -> String {
32 const QUOTE: char = '\'';32 const QUOTE: char = '\'';
33 let mut out = str.replace(QUOTE, "'\"'\"'");33 let mut out = str_.replace(QUOTE, "'\"'\"'");
34 out.insert(0, QUOTE);34 out.insert(0, QUOTE);
35 out.push(QUOTE);35 out.push(QUOTE);
36 out36 out