git.delta.rocks / jrsonnet / refs/commits / 9268ff4f09ce

difftreelog

fix use new ArrValue variants

Yaroslav Bolyukin2021-01-24parent: #00b4f05.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
379 1, to: ty!(number) => Val::Num;379 1, to: ty!(number) => Val::Num;
380 ], {380 ], {
381 if to < from {381 if to < from {
382 return Ok(Val::Arr(Rc::new(Vec::new())))382 return Ok(Val::Arr(ArrValue::new_eager()))
383 }383 }
384 let mut out = Vec::with_capacity((1+to as usize-from as usize).max(0));384 let mut out = Vec::with_capacity((1+to as usize-from as usize).max(0));
385 for i in from as usize..=to as usize {385 for i in from as usize..=to as usize {
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -179,6 +179,10 @@
 	Extended(Box<(Self, Self)>),
 }
 impl ArrValue {
+	pub fn new_eager() -> Self {
+		Self::Eager(Rc::new(Vec::new()))
+	}
+
 	pub fn len(&self) -> usize {
 		match self {
 			Self::Lazy(l) => l.len(),