git.delta.rocks / jrsonnet / refs/commits / 11dc48e90ac0

difftreelog

fix experimental build

Yaroslav Bolyukin2024-05-01parent: #f0883bb.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -110,10 +110,7 @@
 						fn get(self: Box<Self>) -> Result<Self::Output> {
 							let full = self.full.evaluate()?;
 							let to = full.len() - self.end;
-							Ok(Val::Arr(
-								full.slice(Some(self.start), Some(to), None)
-									.expect("arguments checked"),
-							))
+							Ok(Val::Arr(full.slice(Some(self.start as i32), Some(to as i32), None)))
 						}
 					}
 
modifiedcrates/jrsonnet-stdlib/src/manifest/mod.rsdiffbeforeafterboth
before · crates/jrsonnet-stdlib/src/manifest/mod.rs
1mod python;2mod toml;3mod xml;4mod yaml;56use jrsonnet_evaluator::{7	function::builtin,8	manifest::{escape_string_json, JsonFormat, YamlStreamFormat},9	IStr, ObjValue, Result, Val,10};11pub use python::{PythonFormat, PythonVarsFormat};12pub use toml::TomlFormat;13pub use yaml::YamlFormat;14pub use xml::XmlJsonmlFormat;1516#[builtin]17pub fn builtin_escape_string_json(str_: IStr) -> Result<String> {18	Ok(escape_string_json(&str_))19}2021#[builtin]22pub fn builtin_manifest_json_ex(23	value: Val,24	indent: String,25	newline: Option<IStr>,26	key_val_sep: Option<IStr>,2728	#[default(false)]29	#[cfg(feature = "exp-preserve-order")]30	preserve_order: bool,31) -> Result<String> {32	let newline = newline.as_deref().unwrap_or("\n");33	let key_val_sep = key_val_sep.as_deref().unwrap_or(": ");34	value.manifest(JsonFormat::std_to_json(35		indent,36		newline,37		key_val_sep,38		#[cfg(feature = "exp-preserve-order")]39		preserve_order,40	))41}4243#[builtin]44pub fn builtin_manifest_json(45	value: Val,4647	#[default(false)]48	#[cfg(feature = "exp-preserve-order")]49	preserve_order: bool,50) -> Result<String> {51	builtin_manifest_json_ex(52		value,53		"    ".to_owned(),54		None,55		None,56		#[cfg(feature = "exp-preserve-order")]57		preserve_order,58	)59}6061#[builtin]62pub fn builtin_manifest_json_minified(63	value: Val,6465	#[default(false)]66	#[cfg(feature = "exp-preserve-order")]67	preserve_order: bool,68) -> Result<String> {69	value.manifest(JsonFormat::minify(70		#[cfg(feature = "exp-preserve-order")]71		preserve_order,72	))73}7475#[builtin]76pub fn builtin_manifest_yaml_doc(77	value: Val,78	#[default(false)] indent_array_in_object: bool,79	#[default(true)] quote_keys: bool,8081	#[default(false)]82	#[cfg(feature = "exp-preserve-order")]83	preserve_order: bool,84) -> Result<String> {85	value.manifest(YamlFormat::std_to_yaml(86		indent_array_in_object,87		quote_keys,88		#[cfg(feature = "exp-preserve-order")]89		preserve_order,90	))91}9293#[builtin]94pub fn builtin_manifest_yaml_stream(95	value: Val,96	#[default(false)] indent_array_in_object: bool,97	#[default(true)] c_document_end: bool,98	#[default(true)] quote_keys: bool,99100	#[default(false)]101	#[cfg(feature = "exp-preserve-order")]102	preserve_order: bool,103) -> Result<String> {104	value.manifest(YamlStreamFormat::std_yaml_stream(105		YamlFormat::std_to_yaml(106			indent_array_in_object,107			quote_keys,108			#[cfg(feature = "exp-preserve-order")]109			preserve_order,110		),111		c_document_end,112	))113}114115#[builtin]116pub fn builtin_manifest_toml_ex(117	value: ObjValue,118	indent: String,119120	#[default(false)]121	#[cfg(feature = "exp-preserve-order")]122	preserve_order: bool,123) -> Result<String> {124	Val::Obj(value).manifest(TomlFormat::std_to_toml(125		indent,126		#[cfg(feature = "exp-preserve-order")]127		preserve_order,128	))129}130131#[builtin]132pub fn builtin_manifest_toml(133	value: ObjValue,134135	#[default(false)]136	#[cfg(feature = "exp-preserve-order")]137	preserve_order: bool,138) -> Result<String> {139	builtin_manifest_toml_ex(140		value,141		"  ".to_owned(),142		#[cfg(feature = "exp-preserve-order")]143		preserve_order,144	)145}146147#[builtin]148pub fn builtin_to_string(a: Val) -> Result<IStr> {149	a.to_string()150}151152#[builtin]153pub fn builtin_manifest_python(v: Val) -> Result<String> {154	v.manifest(PythonFormat {})155}156#[builtin]157pub fn builtin_manifest_python_vars(v: Val) -> Result<String> {158	v.manifest(PythonVarsFormat {})159}160161#[builtin]162pub fn builtin_escape_string_xml(str_: String) -> String {163	xml::escape_string_xml(str_.as_str())164}165166#[builtin]167pub fn builtin_manifest_xml_jsonml(value: Val) -> Result<String> {168	value.manifest(XmlJsonmlFormat::std_to_xml())169}
after · crates/jrsonnet-stdlib/src/manifest/mod.rs
1mod python;2mod toml;3mod xml;4mod yaml;56use jrsonnet_evaluator::{7	function::builtin,8	manifest::{escape_string_json, JsonFormat, YamlStreamFormat},9	IStr, ObjValue, Result, Val,10};11pub use python::{PythonFormat, PythonVarsFormat};12pub use toml::TomlFormat;13pub use xml::XmlJsonmlFormat;14pub use yaml::YamlFormat;1516#[builtin]17pub fn builtin_escape_string_json(str_: IStr) -> Result<String> {18	Ok(escape_string_json(&str_))19}2021#[builtin]22pub fn builtin_manifest_json_ex(23	value: Val,24	indent: String,25	newline: Option<IStr>,26	key_val_sep: Option<IStr>,2728	#[default(false)]29	#[cfg(feature = "exp-preserve-order")]30	preserve_order: bool,31) -> Result<String> {32	let newline = newline.as_deref().unwrap_or("\n");33	let key_val_sep = key_val_sep.as_deref().unwrap_or(": ");34	value.manifest(JsonFormat::std_to_json(35		indent,36		newline,37		key_val_sep,38		#[cfg(feature = "exp-preserve-order")]39		preserve_order,40	))41}4243#[builtin]44pub fn builtin_manifest_json(45	value: Val,4647	#[default(false)]48	#[cfg(feature = "exp-preserve-order")]49	preserve_order: bool,50) -> Result<String> {51	builtin_manifest_json_ex(52		value,53		"    ".to_owned(),54		None,55		None,56		#[cfg(feature = "exp-preserve-order")]57		preserve_order,58	)59}6061#[builtin]62pub fn builtin_manifest_json_minified(63	value: Val,6465	#[default(false)]66	#[cfg(feature = "exp-preserve-order")]67	preserve_order: bool,68) -> Result<String> {69	value.manifest(JsonFormat::minify(70		#[cfg(feature = "exp-preserve-order")]71		preserve_order,72	))73}7475#[builtin]76pub fn builtin_manifest_yaml_doc(77	value: Val,78	#[default(false)] indent_array_in_object: bool,79	#[default(true)] quote_keys: bool,8081	#[default(false)]82	#[cfg(feature = "exp-preserve-order")]83	preserve_order: bool,84) -> Result<String> {85	value.manifest(YamlFormat::std_to_yaml(86		indent_array_in_object,87		quote_keys,88		#[cfg(feature = "exp-preserve-order")]89		preserve_order,90	))91}9293#[builtin]94pub fn builtin_manifest_yaml_stream(95	value: Val,96	#[default(false)] indent_array_in_object: bool,97	#[default(true)] c_document_end: bool,98	#[default(true)] quote_keys: bool,99100	#[default(false)]101	#[cfg(feature = "exp-preserve-order")]102	preserve_order: bool,103) -> Result<String> {104	value.manifest(YamlStreamFormat::std_yaml_stream(105		YamlFormat::std_to_yaml(106			indent_array_in_object,107			quote_keys,108			#[cfg(feature = "exp-preserve-order")]109			preserve_order,110		),111		c_document_end,112	))113}114115#[builtin]116pub fn builtin_manifest_toml_ex(117	value: ObjValue,118	indent: String,119120	#[default(false)]121	#[cfg(feature = "exp-preserve-order")]122	preserve_order: bool,123) -> Result<String> {124	Val::Obj(value).manifest(TomlFormat::std_to_toml(125		indent,126		#[cfg(feature = "exp-preserve-order")]127		preserve_order,128	))129}130131#[builtin]132pub fn builtin_manifest_toml(133	value: ObjValue,134135	#[default(false)]136	#[cfg(feature = "exp-preserve-order")]137	preserve_order: bool,138) -> Result<String> {139	builtin_manifest_toml_ex(140		value,141		"  ".to_owned(),142		#[cfg(feature = "exp-preserve-order")]143		preserve_order,144	)145}146147#[builtin]148pub fn builtin_to_string(a: Val) -> Result<IStr> {149	a.to_string()150}151152#[builtin]153pub fn builtin_manifest_python(154	v: Val,155156	#[default(false)]157	#[cfg(feature = "exp-preserve-order")]158	preserve_order: bool,159) -> Result<String> {160	v.manifest(PythonFormat::std(161		#[cfg(feature = "exp-preserve-order")]162		preserve_order,163	))164}165#[builtin]166pub fn builtin_manifest_python_vars(167	v: Val,168169	#[default(false)]170	#[cfg(feature = "exp-preserve-order")]171	preserve_order: bool,172) -> Result<String> {173	v.manifest(PythonVarsFormat::std(174		#[cfg(feature = "exp-preserve-order")]175		preserve_order,176	))177}178179#[builtin]180pub fn builtin_escape_string_xml(str_: String) -> String {181	xml::escape_string_xml(str_.as_str())182}183184#[builtin]185pub fn builtin_manifest_xml_jsonml(value: Val) -> Result<String> {186	value.manifest(XmlJsonmlFormat::std_to_xml())187}
modifiedcrates/jrsonnet-stdlib/src/manifest/python.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/manifest/python.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/python.rs
@@ -9,6 +9,15 @@
 	preserve_order: bool,
 }
 
+impl PythonFormat {
+	pub fn std(#[cfg(feature = "exp-preserve-order")] preserve_order: bool) -> Self {
+		Self {
+			#[cfg(feature = "exp-preserve-order")]
+			preserve_order,
+		}
+	}
+}
+
 impl ManifestFormat for PythonFormat {
 	fn manifest_buf(&self, val: Val, buf: &mut String) -> Result<()> {
 		match val {
@@ -17,6 +26,8 @@
 			Val::Null => buf.push_str("None"),
 			Val::Str(s) => escape_string_json_buf(&s.to_string(), buf),
 			Val::Num(_) => ToStringFormat.manifest_buf(val, buf)?,
+			#[cfg(feature = "exp-bigint")]
+			Val::BigInt(_) => ToStringFormat.manifest_buf(val, buf)?,
 			Val::Arr(arr) => {
 				buf.push('[');
 				for (i, el) in arr.iter().enumerate() {
@@ -57,7 +68,14 @@
 	preserve_order: bool,
 }
 
-impl PythonVarsFormat {}
+impl PythonVarsFormat {
+	pub fn std(#[cfg(feature = "exp-preserve-order")] preserve_order: bool) -> Self {
+		Self {
+			#[cfg(feature = "exp-preserve-order")]
+			preserve_order,
+		}
+	}
+}
 
 impl ManifestFormat for PythonVarsFormat {
 	fn manifest_buf(&self, val: Val, buf: &mut String) -> Result<()> {
modifiedcrates/jrsonnet-stdlib/src/manifest/xml.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/manifest/xml.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/xml.rs
@@ -95,7 +95,11 @@
 			buf.push('<');
 			buf.push_str(&tag);
 			attrs.run_assertions()?;
-			for (key, value) in attrs.iter() {
+			for (key, value) in attrs.iter(
+				// Not much sense to preserve order here
+				#[cfg(feature = "exp-preserve-order")]
+				false,
+			) {
 				buf.push(' ');
 				buf.push_str(&key);
 				buf.push('=');