From 0a86b5ba47230580dbe2a8ae033e91c5cac8c165 Mon Sep 17 00:00:00 2001 From: frozolotl <44589151+frozolotl@users.noreply.github.com> Date: Fri, 29 Aug 2025 20:27:20 +0200 Subject: [PATCH] Follow the comment on setting the `State`'s mask (#6642) --- crates/typst-render/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/typst-render/src/lib.rs b/crates/typst-render/src/lib.rs index 2b717b3b..8856b086 100644 --- a/crates/typst-render/src/lib.rs +++ b/crates/typst-render/src/lib.rs @@ -93,7 +93,7 @@ struct State<'a> { size: Size, } -impl State<'_> { +impl<'a> State<'a> { fn new(size: Size, transform: sk::Transform, pixel_per_pt: f32) -> Self { Self { size, @@ -128,9 +128,10 @@ impl State<'_> { } /// Sets the current mask. - fn with_mask(self, mask: Option<&sk::Mask>) -> State<'_> { - // Ensure that we're using the parent's mask if we don't have one. - if mask.is_some() { State { mask, ..self } } else { State { mask: None, ..self } } + /// + /// If no mask is provided, the parent mask is used. + fn with_mask(self, mask: Option<&'a sk::Mask>) -> State<'a> { + State { mask: mask.or(self.mask), ..self } } /// Sets the size of the first hard frame in the hierarchy.