From 8ba11b0722599892499337b3272cec38945d11de Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 27 May 2022 16:37:03 +0200 Subject: [PATCH] Reword --- src/frame.rs | 3 ++- src/model/locate.rs | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/frame.rs b/src/frame.rs index 2ece51476..2a16b6f21 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -219,7 +219,8 @@ pub enum Element { Image(ImageId, Size), /// A link to an external resource and its trigger region. Link(Destination, Size), - /// A pin identified by index. + /// A pin identified by index. This is used to find elements on the pages + /// and use their location in formatting. Exporters can just ignore it. Pin(usize), } diff --git a/src/model/locate.rs b/src/model/locate.rs index c61facc55..97c140349 100644 --- a/src/model/locate.rs +++ b/src/model/locate.rs @@ -85,7 +85,7 @@ struct SingleNode(Spanned); impl SingleNode { fn realize(&self, ctx: &mut Context) -> TypResult { let idx = ctx.pins.cursor(); - let pin = ctx.pins.next(None, None); + let pin = ctx.pins.get_or_create(None, None); let dict = pin.encode(None); let args = Args::new(self.0.span, [Value::Dict(dict)]); Ok(Content::Pin(idx) + self.0.v.call_detached(ctx, args)?.display()) @@ -106,7 +106,7 @@ struct EntryNode { impl EntryNode { fn realize(&self, ctx: &mut Context) -> TypResult { let idx = ctx.pins.cursor(); - let pin = ctx.pins.next(Some(self.group.clone()), self.value.clone()); + let pin = ctx.pins.get_or_create(Some(self.group.clone()), self.value.clone()); // Determine the index among the peers. let index = ctx @@ -231,8 +231,8 @@ impl PinBoard { self.list.len() - self.list.iter().zip(&prev.list).filter(|(a, b)| a == b).count() } - /// Access the next pin. - fn next(&mut self, group: Option, value: Option) -> Pin { + /// Access or create the next pin. + fn get_or_create(&mut self, group: Option, value: Option) -> Pin { if self.frozen() { return Pin::default(); }