diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-29 15:09:54 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-29 15:09:54 +0200 |
| commit | e4e79990dad90aea17ea99e54fcd60435927bb56 (patch) | |
| tree | 2e893ac5e104867629c2dad38502ef3fdc426d33 /src/eval/template.rs | |
| parent | 411aba5b6f541f96bbdb4e23a40cf022a867dc11 (diff) | |
Allow body for font function once again
Diffstat (limited to 'src/eval/template.rs')
| -rw-r--r-- | src/eval/template.rs | 13 |
1 files changed, 13 insertions, 0 deletions
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<F>(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 { |
