Skip to content

Commit

Permalink
feat: add std.isEmpty
Browse files Browse the repository at this point in the history
Upstream issue: google/go-jsonnet#678
  • Loading branch information
pawelbeza committed Jul 11, 2023
1 parent 0319252 commit 83c939e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/jrsonnet-stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub fn stdlib_uncached(settings: Rc<RefCell<Settings>>) -> 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),
Expand Down
5 changes: 5 additions & 0 deletions crates/jrsonnet-stdlib/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down

0 comments on commit 83c939e

Please sign in to comment.