difftreelog
fix experimental build
in: master
4 files changed
crates/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)))
}
}
crates/jrsonnet-stdlib/src/manifest/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-stdlib/src/manifest/mod.rs
+++ b/crates/jrsonnet-stdlib/src/manifest/mod.rs
@@ -10,8 +10,8 @@
};
pub use python::{PythonFormat, PythonVarsFormat};
pub use toml::TomlFormat;
+pub use xml::XmlJsonmlFormat;
pub use yaml::YamlFormat;
-pub use xml::XmlJsonmlFormat;
#[builtin]
pub fn builtin_escape_string_json(str_: IStr) -> Result<String> {
@@ -150,12 +150,30 @@
}
#[builtin]
-pub fn builtin_manifest_python(v: Val) -> Result<String> {
- v.manifest(PythonFormat {})
+pub fn builtin_manifest_python(
+ v: Val,
+
+ #[default(false)]
+ #[cfg(feature = "exp-preserve-order")]
+ preserve_order: bool,
+) -> Result<String> {
+ v.manifest(PythonFormat::std(
+ #[cfg(feature = "exp-preserve-order")]
+ preserve_order,
+ ))
}
#[builtin]
-pub fn builtin_manifest_python_vars(v: Val) -> Result<String> {
- v.manifest(PythonVarsFormat {})
+pub fn builtin_manifest_python_vars(
+ v: Val,
+
+ #[default(false)]
+ #[cfg(feature = "exp-preserve-order")]
+ preserve_order: bool,
+) -> Result<String> {
+ v.manifest(PythonVarsFormat::std(
+ #[cfg(feature = "exp-preserve-order")]
+ preserve_order,
+ ))
}
#[builtin]
crates/jrsonnet-stdlib/src/manifest/python.rsdiffbeforeafterboth1use jrsonnet_evaluator::{2 bail,3 manifest::{escape_string_json_buf, ManifestFormat, ToStringFormat},4 Result, Val,5};67pub struct PythonFormat {8 #[cfg(feature = "exp-preserve-order")]9 preserve_order: bool,10}1112impl ManifestFormat for PythonFormat {13 fn manifest_buf(&self, val: Val, buf: &mut String) -> Result<()> {14 match val {15 Val::Bool(true) => buf.push_str("True"),16 Val::Bool(false) => buf.push_str("False"),17 Val::Null => buf.push_str("None"),18 Val::Str(s) => escape_string_json_buf(&s.to_string(), buf),19 Val::Num(_) => ToStringFormat.manifest_buf(val, buf)?,20 Val::Arr(arr) => {21 buf.push('[');22 for (i, el) in arr.iter().enumerate() {23 let el = el?;24 if i != 0 {25 buf.push_str(", ");26 }27 self.manifest_buf(el, buf)?;28 }29 buf.push(']');30 }31 Val::Obj(obj) => {32 obj.run_assertions()?;33 buf.push('{');34 let fields = obj.fields(35 #[cfg(feature = "exp-preserve-order")]36 self.preserve_order,37 );38 for (i, field) in fields.into_iter().enumerate() {39 if i != 0 {40 buf.push_str(", ");41 }42 escape_string_json_buf(&field, buf);43 buf.push_str(": ");44 let value = obj.get(field)?.expect("field exists");45 self.manifest_buf(value, buf)?;46 }47 buf.push('}');48 }49 Val::Func(_) => bail!("tried to manifest function"),50 }51 Ok(())52 }53}5455pub struct PythonVarsFormat {56 #[cfg(feature = "exp-preserve-order")]57 preserve_order: bool,58}5960impl PythonVarsFormat {}6162impl ManifestFormat for PythonVarsFormat {63 fn manifest_buf(&self, val: Val, buf: &mut String) -> Result<()> {64 let inner = PythonFormat {65 #[cfg(feature = "exp-preserve-order")]66 preserve_order: self.preserve_order,67 };68 let Val::Obj(obj) = val else {69 bail!("python vars root should be object");70 };71 obj.run_assertions()?;7273 let fields = obj.fields(74 #[cfg(feature = "exp-preserve-order")]75 self.preserve_order,76 );7778 for field in fields {79 // Yep, no escaping80 buf.push_str(&field);81 buf.push_str(" = ");82 inner.manifest_buf(obj.get(field)?.expect("field exists"), buf)?;83 buf.push('\n');84 }85 Ok(())86 }87}crates/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('=');