From ef3795cb9b94e948eccc29bc1c8e3ec488b691d3 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 27 Apr 2024 17:35:20 +0200 Subject: [PATCH] pass in allocator to post-eval callback --- src/run_program.rs | 4 ++-- src/test_ops.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/run_program.rs b/src/run_program.rs index 0a3fad2b..44552835 100644 --- a/src/run_program.rs +++ b/src/run_program.rs @@ -24,7 +24,7 @@ pub type PreEval = Box Result>, EvalErr>>; #[cfg(feature = "pre-eval")] -pub type PostEval = dyn Fn(Option); +pub type PostEval = dyn Fn(&mut Allocator, Option); #[repr(u8)] enum Operation { @@ -495,7 +495,7 @@ impl<'a, D: Dialect> RunProgramContext<'a, D> { Operation::PostEval => { let f = self.posteval_stack.pop().unwrap(); let peek: Option = self.val_stack.last().copied(); - f(peek); + f(&mut self.allocator, peek); 0 } }; diff --git a/src/test_ops.rs b/src/test_ops.rs index f4ee7dd1..8d535829 100644 --- a/src/test_ops.rs +++ b/src/test_ops.rs @@ -413,7 +413,7 @@ fn test_pre_eval_and_post_eval() { &mut Allocator, NodePtr, NodePtr, - ) -> Result))>>, EvalErr>, + ) -> Result))>>, EvalErr>, > = Box::new(move |_allocator, prog, args| { let tracking_key = pre_eval_tracking.borrow().len(); // Ensure lifetime of mutable borrow is contained. @@ -430,7 +430,7 @@ fn test_pre_eval_and_post_eval() { ); } let post_eval_tracking = pre_eval_tracking.clone(); - let post_eval_f: Box)> = Box::new(move |outcome| { + let post_eval_f: Box)> = Box::new(move |_a, outcome| { let mut tracking_mutable = post_eval_tracking.borrow_mut(); tracking_mutable.insert( tracking_key,