diff --git a/crates/jrsonnet-stdlib/src/lib.rs b/crates/jrsonnet-stdlib/src/lib.rs index 9ceb7495..dc304f5f 100644 --- a/crates/jrsonnet-stdlib/src/lib.rs +++ b/crates/jrsonnet-stdlib/src/lib.rs @@ -148,6 +148,7 @@ pub fn stdlib_uncached(settings: Rc>) -> ObjValue { ("substr", builtin_substr::INST), ("char", builtin_char::INST), ("strReplace", builtin_str_replace::INST), + ("isEmpty", builtin_is_empty::INST), ("splitLimit", builtin_splitlimit::INST), ("asciiUpper", builtin_ascii_upper::INST), ("asciiLower", builtin_ascii_lower::INST), diff --git a/crates/jrsonnet-stdlib/src/strings.rs b/crates/jrsonnet-stdlib/src/strings.rs index 7eee830e..770e7aca 100644 --- a/crates/jrsonnet-stdlib/src/strings.rs +++ b/crates/jrsonnet-stdlib/src/strings.rs @@ -27,6 +27,11 @@ pub fn builtin_str_replace(str: String, from: IStr, to: IStr) -> String { str.replace(&from as &str, &to as &str) } +#[builtin] +pub fn builtin_is_empty(str: String) -> bool { + str.is_empty() +} + #[builtin] pub fn builtin_splitlimit(str: IStr, c: IStr, maxsplits: Either![usize, M1]) -> ArrValue { use Either2::*;