difftreelog
fix ObjValue is_empty should not account hidden fields
in: master
2 files changed
crates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -669,17 +669,18 @@
}
fn len(&self) -> usize {
+ // Maybe it will be better to not compute sort key here?
self.fields_visibility()
.into_iter()
.filter(|(_, (visible, _))| *visible)
.count()
}
+ /// Returns false only if there is any visible entry.
+ ///
+ /// Note that object with hidden fields `{a:: 1}` will be reported as empty here.
fn is_empty(&self) -> bool {
- if !self.this_entries.is_empty() {
- return false;
- }
- self.sup.as_ref().map_or(true, ObjValue::is_empty)
+ self.len() != 0
}
/// Run callback for every field found in object
crates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth28}28}292930#[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