difftreelog
Merge branch 'master' of github.com:CertainLach/jrsonnet into type-safety
in: master
3 files changed
cmds/jrsonnet/src/main.rsdiffbeforeafterboth--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -136,7 +136,10 @@
let mut file = File::create(path)?;
writeln!(file, "{}", state.manifest(val)?)?;
} else {
- println!("{}", state.manifest(val)?);
+ let output = state.manifest(val)?;
+ if !output.is_empty() {
+ println!("{}", output);
+ }
}
Ok(())
crates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth74 } else if mtype == ManifestType::Std {74 } else if mtype == ManifestType::Std {75 buf.push_str("\n\n");75 buf.push_str("\n\n");76 buf.push_str(cur_padding);76 buf.push_str(cur_padding);77 } else if mtype == ManifestType::ToString {77 } else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {78 buf.push(' ');78 buf.push(' ');79 }79 }80 buf.push(']');80 buf.push(']');112 } else if mtype == ManifestType::Std {112 } else if mtype == ManifestType::Std {113 buf.push_str("\n\n");113 buf.push_str("\n\n");114 buf.push_str(cur_padding);114 buf.push_str(cur_padding);115 } else if mtype == ManifestType::ToString {115 } else if mtype == ManifestType::ToString || mtype == ManifestType::Manifest {116 buf.push(' ');116 buf.push(' ');117 }117 }118 buf.push('}');118 buf.push('}');crates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -378,6 +378,9 @@
0, from: ty!(number) => Val::Num;
1, to: ty!(number) => Val::Num;
], {
+ if to < from {
+ return Ok(Val::Arr(Rc::new(Vec::new())))
+ }
let mut out = Vec::with_capacity((1+to as usize-from as usize).max(0));
for i in from as usize..=to as usize {
out.push(Val::Num(i as f64));