difftreelog
fix ToStringFormat should not quote top-level string
in: master
2 files changed
crates/jrsonnet-evaluator/src/manifest.rsdiffbeforeafterboth84 debug_truncate_strings: None,84 debug_truncate_strings: None,85 }85 }86 }86 }87 // Same format as std.toString87 /// Same format as std.toString, except does not keeps top-level string as-is88 /// To avoid confusion, the format is private in jrsonnet, use [`ToStringFormat`] instead88 pub fn std_to_string() -> Self {89 const fn std_to_string_helper() -> Self {89 Self {90 Self {90 padding: Cow::Borrowed(""),91 padding: Cow::Borrowed(""),91 mtype: JsonFormatting::ToString,92 mtype: JsonFormatting::ToString,344 }345 }345}346}346347348/// Same as [`JsonFormat`] with pre-set options, but top-level string is serialized as-is,349/// without quoting.347pub struct ToStringFormat;350pub struct ToStringFormat;348impl ManifestFormat for ToStringFormat {351impl ManifestFormat for ToStringFormat {349 fn manifest_buf(&self, val: Val, out: &mut String) -> Result<()> {352 fn manifest_buf(&self, val: Val, out: &mut String) -> Result<()> {350 JsonFormat::std_to_string().manifest_buf(val, out)353 const JSON_TO_STRING: JsonFormat = JsonFormat::std_to_string_helper();354 if let Some(str) = val.as_str() {355 out.push_str(&str);356 return Ok(());357 }358 JSON_TO_STRING.manifest_buf(val, out)351 }359 }352 fn file_trailing_newline(&self) -> bool {360 fn file_trailing_newline(&self) -> bool {353 false361 falsecrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth132 Optional,132 Optional,133 Default(Expr),133 Default(Expr),134}134}135impl Optionality {136 fn is_optional(&self) -> bool {137 !matches!(self, Self::Required)138 }139}140135141enum ArgInfo {136enum ArgInfo {142 Normal {137 Normal {