Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: missing std features #124

Conversation

pawelbeza
Copy link
Contributor

Hey 👋
I've implemented missing std features which were listed in the #118

You can test new features with the following jsonnet snippet:

{
	local test = ["a", "b", "a"],
	local obj = {a: "1", b: "2", c:: "3"},
	round1: std.round(1.0),
	round2: std.round(1.2),
	round3: std.round(1.5),
	isEven1: std.isEven(1),
	isEven2: std.isEven(2),
	isOdd1: std.isOdd(1),
	isOdd2: std.isOdd(2),
	isInteger1: std.isInteger(1.0),
	isInteger2: std.isInteger(1.1),
	isDecimal1: std.isDecimal(1.0),
	isDecimal2: std.isDecimal(1.1),
	xnortt: std.xnor(true, true),
	xnortf: std.xnor(true, false),
	xnorff: std.xnor(false, false),
	isEmpty1: std.isEmpty(""),
	isEmpty2: std.isEmpty(" "),
	isEmpty3: std.isEmpty("abc"),
	equalsIgnoreCase1: std.equalsIgnoreCase("a", "ac"),
	equalsIgnoreCase2: std.equalsIgnoreCase("a", "a"),
	equalsIgnoreCase3: std.equalsIgnoreCase("aB", "ab"),
	equalsIgnoreCase4: std.equalsIgnoreCase("aB", "Ab"),
	sha1: std.sha1("abcd"),
	sha3: std.sha3("abcd"),
	remove1: std.remove(["a", "b", "a"], "a"),
	remove2: std.remove(["a", "b", "a"], "c"),
	remove3: std.remove(test, "b"),
	remove4: test,
	remove5: std.removeAt(["a", "b", "a"], 0),
	remove6: std.removeAt(["a", "b", "a"], 1),
	remove7: std.removeAt(["a", "b", "a"], 4),
	objectRemoveKey1: std.objectRemoveKey(obj, "b"),
	objectRemoveKey2: std.objectRemoveKey(obj, "c"),
	objectRemoveKey3: obj,
	objectKeyValues: std.objectKeysValues(obj),
	objectKeyValuesAll: std.objectKeysValuesAll(obj)
}

Feel free to leave comments as that's my first time writing some Rust code.

@pawelbeza pawelbeza changed the title Missing std features feat: missing std features Jul 14, 2023
@pawelbeza
Copy link
Contributor Author

Hey @CertainLach sorry for ping but I guess you might be interested in looking into this. Cheers

Copy link
Owner

@CertainLach CertainLach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Everything looks fine, except of std.remove implementation, which may crash

crates/jrsonnet-stdlib/src/arrays.rs Outdated Show resolved Hide resolved
@pawelbeza pawelbeza force-pushed the missing-std-features branch from c22df0f to 150dfd2 Compare July 15, 2023 18:15
@pawelbeza pawelbeza requested a review from CertainLach July 15, 2023 18:16
Copy link
Owner

@CertainLach CertainLach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@CertainLach CertainLach merged commit b63c39c into CertainLach:feature/upstream-std-sync Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants