From e4e79990dad90aea17ea99e54fcd60435927bb56 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 29 Aug 2021 15:09:54 +0200 Subject: Allow body for font function once again --- src/eval/template.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/eval') diff --git a/src/eval/template.rs b/src/eval/template.rs index 4fc6985a..f4feda40 100644 --- a/src/eval/template.rs +++ b/src/eval/template.rs @@ -140,6 +140,19 @@ impl Template { self.make_mut().push(TemplateNode::Modify(Rc::new(f))); } + /// Return a new template which is modified from start to end. + pub fn modified(self, f: F) -> Self + where + F: Fn(&mut State) + 'static, + { + let mut wrapper = Self::new(); + wrapper.save(); + wrapper.modify(f); + wrapper += self; + wrapper.restore(); + wrapper + } + /// Build the stack node resulting from instantiating the template in the /// given state. pub fn to_stack(&self, state: &State) -> StackNode { -- cgit v1.2.3