Skip to content

Commit 83c939e

Browse files
committed
feat: add std.isEmpty
Upstream issue: google/go-jsonnet#678
1 parent 0319252 commit 83c939e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

crates/jrsonnet-stdlib/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub fn stdlib_uncached(settings: Rc<RefCell<Settings>>) -> ObjValue {
148148
("substr", builtin_substr::INST),
149149
("char", builtin_char::INST),
150150
("strReplace", builtin_str_replace::INST),
151+
("isEmpty", builtin_is_empty::INST),
151152
("splitLimit", builtin_splitlimit::INST),
152153
("asciiUpper", builtin_ascii_upper::INST),
153154
("asciiLower", builtin_ascii_lower::INST),

crates/jrsonnet-stdlib/src/strings.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ pub fn builtin_str_replace(str: String, from: IStr, to: IStr) -> String {
2727
str.replace(&from as &str, &to as &str)
2828
}
2929

30+
#[builtin]
31+
pub fn builtin_is_empty(str: String) -> bool {
32+
str.is_empty()
33+
}
34+
3035
#[builtin]
3136
pub fn builtin_splitlimit(str: IStr, c: IStr, maxsplits: Either![usize, M1]) -> ArrValue {
3237
use Either2::*;

0 commit comments

Comments
 (0)