summaryrefslogtreecommitdiff
path: root/crates/typst-library/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-01-10 17:54:11 +0100
committerGitHub <noreply@github.com>2025-01-10 16:54:11 +0000
commit6b9b78596a6103dfbcadafaeb03eda624da5306a (patch)
tree073a9e31f504634290337c20432ea13dc7a8953d /crates/typst-library/src
parent9473aface183feaf48601c5264c3604f5798169e (diff)
Don't generate accessors for required fields (#5680)
Diffstat (limited to 'crates/typst-library/src')
-rw-r--r--crates/typst-library/src/introspection/counter.rs2
-rw-r--r--crates/typst-library/src/introspection/state.rs2
-rw-r--r--crates/typst-library/src/layout/align.rs2
-rw-r--r--crates/typst-library/src/layout/container.rs2
-rw-r--r--crates/typst-library/src/layout/grid/mod.rs2
-rw-r--r--crates/typst-library/src/layout/grid/resolve.rs12
-rw-r--r--crates/typst-library/src/layout/hide.rs2
-rw-r--r--crates/typst-library/src/layout/layout.rs2
-rw-r--r--crates/typst-library/src/math/accent.rs2
-rw-r--r--crates/typst-library/src/math/attach.rs4
-rw-r--r--crates/typst-library/src/model/bibliography.rs9
-rw-r--r--crates/typst-library/src/model/figure.rs17
-rw-r--r--crates/typst-library/src/model/footnote.rs15
-rw-r--r--crates/typst-library/src/model/heading.rs4
-rw-r--r--crates/typst-library/src/model/link.rs7
-rw-r--r--crates/typst-library/src/model/outline.rs13
-rw-r--r--crates/typst-library/src/model/quote.rs2
-rw-r--r--crates/typst-library/src/model/reference.rs14
-rw-r--r--crates/typst-library/src/model/table.rs2
-rw-r--r--crates/typst-library/src/model/terms.rs6
-rw-r--r--crates/typst-library/src/text/deco.rs8
-rw-r--r--crates/typst-library/src/text/mod.rs2
-rw-r--r--crates/typst-library/src/text/raw.rs8
-rw-r--r--crates/typst-library/src/text/shift.rs8
-rw-r--r--crates/typst-library/src/text/smallcaps.rs2
25 files changed, 71 insertions, 78 deletions
diff --git a/crates/typst-library/src/introspection/counter.rs b/crates/typst-library/src/introspection/counter.rs
index e189103d..d26a9f9f 100644
--- a/crates/typst-library/src/introspection/counter.rs
+++ b/crates/typst-library/src/introspection/counter.rs
@@ -800,7 +800,7 @@ impl ManualPageCounter {
let Some(elem) = elem.to_packed::<CounterUpdateElem>() else {
continue;
};
- if *elem.key() == CounterKey::Page {
+ if elem.key == CounterKey::Page {
let mut state = CounterState(smallvec![self.logical]);
state.update(engine, elem.update.clone())?;
self.logical = state.first();
diff --git a/crates/typst-library/src/introspection/state.rs b/crates/typst-library/src/introspection/state.rs
index 7e019e6c..e6ab926b 100644
--- a/crates/typst-library/src/introspection/state.rs
+++ b/crates/typst-library/src/introspection/state.rs
@@ -245,7 +245,7 @@ impl State {
for elem in introspector.query(&self.selector()) {
let elem = elem.to_packed::<StateUpdateElem>().unwrap();
- match elem.update() {
+ match &elem.update {
StateUpdate::Set(value) => state = value.clone(),
StateUpdate::Func(func) => {
state = func.call(&mut engine, Context::none().track(), [state])?
diff --git a/crates/typst-library/src/layout/align.rs b/crates/typst-library/src/layout/align.rs
index e8ba4d7c..5604d683 100644
--- a/crates/typst-library/src/layout/align.rs
+++ b/crates/typst-library/src/layout/align.rs
@@ -100,7 +100,7 @@ pub struct AlignElem {
impl Show for Packed<AlignElem> {
#[typst_macros::time(name = "align", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().aligned(self.alignment(styles)))
+ Ok(self.body.clone().aligned(self.alignment(styles)))
}
}
diff --git a/crates/typst-library/src/layout/container.rs b/crates/typst-library/src/layout/container.rs
index 266d1d88..c8c74269 100644
--- a/crates/typst-library/src/layout/container.rs
+++ b/crates/typst-library/src/layout/container.rs
@@ -166,7 +166,7 @@ impl Packed<InlineElem> {
styles: StyleChain,
region: Size,
) -> SourceResult<Vec<InlineItem>> {
- self.body().call(engine, locator, styles, region)
+ self.body.call(engine, locator, styles, region)
}
}
diff --git a/crates/typst-library/src/layout/grid/mod.rs b/crates/typst-library/src/layout/grid/mod.rs
index e46440fb..6616c331 100644
--- a/crates/typst-library/src/layout/grid/mod.rs
+++ b/crates/typst-library/src/layout/grid/mod.rs
@@ -749,7 +749,7 @@ cast! {
impl Show for Packed<GridCell> {
fn show(&self, _engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- show_grid_cell(self.body().clone(), self.inset(styles), self.align(styles))
+ show_grid_cell(self.body.clone(), self.inset(styles), self.align(styles))
}
}
diff --git a/crates/typst-library/src/layout/grid/resolve.rs b/crates/typst-library/src/layout/grid/resolve.rs
index adaff1c1..504159e8 100644
--- a/crates/typst-library/src/layout/grid/resolve.rs
+++ b/crates/typst-library/src/layout/grid/resolve.rs
@@ -42,16 +42,16 @@ pub fn grid_to_cellgrid<'a>(
// Use trace to link back to the grid when a specific cell errors
let tracepoint = || Tracepoint::Call(Some(eco_format!("grid")));
let resolve_item = |item: &GridItem| grid_item_to_resolvable(item, styles);
- let children = elem.children().iter().map(|child| match child {
+ let children = elem.children.iter().map(|child| match child {
GridChild::Header(header) => ResolvableGridChild::Header {
repeat: header.repeat(styles),
span: header.span(),
- items: header.children().iter().map(resolve_item),
+ items: header.children.iter().map(resolve_item),
},
GridChild::Footer(footer) => ResolvableGridChild::Footer {
repeat: footer.repeat(styles),
span: footer.span(),
- items: footer.children().iter().map(resolve_item),
+ items: footer.children.iter().map(resolve_item),
},
GridChild::Item(item) => {
ResolvableGridChild::Item(grid_item_to_resolvable(item, styles))
@@ -95,16 +95,16 @@ pub fn table_to_cellgrid<'a>(
// Use trace to link back to the table when a specific cell errors
let tracepoint = || Tracepoint::Call(Some(eco_format!("table")));
let resolve_item = |item: &TableItem| table_item_to_resolvable(item, styles);
- let children = elem.children().iter().map(|child| match child {
+ let children = elem.children.iter().map(|child| match child {
TableChild::Header(header) => ResolvableGridChild::Header {
repeat: header.repeat(styles),
span: header.span(),
- items: header.children().iter().map(resolve_item),
+ items: header.children.iter().map(resolve_item),
},
TableChild::Footer(footer) => ResolvableGridChild::Footer {
repeat: footer.repeat(styles),
span: footer.span(),
- items: footer.children().iter().map(resolve_item),
+ items: footer.children.iter().map(resolve_item),
},
TableChild::Item(item) => {
ResolvableGridChild::Item(table_item_to_resolvable(item, styles))
diff --git a/crates/typst-library/src/layout/hide.rs b/crates/typst-library/src/layout/hide.rs
index 1b8b9bd5..eca33471 100644
--- a/crates/typst-library/src/layout/hide.rs
+++ b/crates/typst-library/src/layout/hide.rs
@@ -29,6 +29,6 @@ pub struct HideElem {
impl Show for Packed<HideElem> {
#[typst_macros::time(name = "hide", span = self.span())]
fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().styled(HideElem::set_hidden(true)))
+ Ok(self.body.clone().styled(HideElem::set_hidden(true)))
}
}
diff --git a/crates/typst-library/src/layout/layout.rs b/crates/typst-library/src/layout/layout.rs
index c3d112e1..05e4f6d9 100644
--- a/crates/typst-library/src/layout/layout.rs
+++ b/crates/typst-library/src/layout/layout.rs
@@ -89,7 +89,7 @@ impl Show for Packed<LayoutElem> {
let loc = elem.location().unwrap();
let context = Context::new(Some(loc), Some(styles));
let result = elem
- .func()
+ .func
.call(
engine,
context.track(),
diff --git a/crates/typst-library/src/math/accent.rs b/crates/typst-library/src/math/accent.rs
index fee705ee..b87e527f 100644
--- a/crates/typst-library/src/math/accent.rs
+++ b/crates/typst-library/src/math/accent.rs
@@ -143,7 +143,7 @@ cast! {
self => self.0.into_value(),
v: char => Self::new(v),
v: Content => match v.to_packed::<TextElem>() {
- Some(elem) => Value::Str(elem.text().clone().into()).cast()?,
+ Some(elem) => Value::Str(elem.text.clone().into()).cast()?,
None => bail!("expected text"),
},
}
diff --git a/crates/typst-library/src/math/attach.rs b/crates/typst-library/src/math/attach.rs
index e1f57727..d526aba5 100644
--- a/crates/typst-library/src/math/attach.rs
+++ b/crates/typst-library/src/math/attach.rs
@@ -47,9 +47,9 @@ impl Packed<AttachElem> {
/// base AttachElem where possible.
pub fn merge_base(&self) -> Option<Self> {
// Extract from an EquationElem.
- let mut base = self.base();
+ let mut base = &self.base;
while let Some(equation) = base.to_packed::<EquationElem>() {
- base = equation.body();
+ base = &equation.body;
}
// Move attachments from elem into base where possible.
diff --git a/crates/typst-library/src/model/bibliography.rs b/crates/typst-library/src/model/bibliography.rs
index 4ab4ff22..95db8a22 100644
--- a/crates/typst-library/src/model/bibliography.rs
+++ b/crates/typst-library/src/model/bibliography.rs
@@ -638,7 +638,7 @@ impl<'a> Generator<'a> {
for elem in &self.groups {
let group = elem.to_packed::<CiteGroup>().unwrap();
let location = elem.location().unwrap();
- let children = group.children();
+ let children = &group.children;
// Groups should never be empty.
let Some(first) = children.first() else { continue };
@@ -650,12 +650,11 @@ impl<'a> Generator<'a> {
// Create infos and items for each child in the group.
for child in children {
- let key = *child.key();
- let Some(entry) = database.get(key) else {
+ let Some(entry) = database.get(child.key) else {
errors.push(error!(
child.span(),
"key `{}` does not exist in the bibliography",
- key.resolve()
+ child.key.resolve()
));
continue;
};
@@ -682,7 +681,7 @@ impl<'a> Generator<'a> {
};
normal &= special_form.is_none();
- subinfos.push(CiteInfo { key, supplement, hidden });
+ subinfos.push(CiteInfo { key: child.key, supplement, hidden });
items.push(CitationItem::new(entry, locator, None, hidden, special_form));
}
diff --git a/crates/typst-library/src/model/figure.rs b/crates/typst-library/src/model/figure.rs
index fd843ee5..52dca966 100644
--- a/crates/typst-library/src/model/figure.rs
+++ b/crates/typst-library/src/model/figure.rs
@@ -257,7 +257,7 @@ impl Synthesize for Packed<FigureElem> {
// Determine the figure's kind.
let kind = elem.kind(styles).unwrap_or_else(|| {
- elem.body()
+ elem.body
.query_first(&Selector::can::<dyn Figurable>())
.map(|elem| FigureKind::Elem(elem.func()))
.unwrap_or_else(|| FigureKind::Elem(ImageElem::elem()))
@@ -288,14 +288,13 @@ impl Synthesize for Packed<FigureElem> {
// Resolve the supplement with the first descendant of the kind or
// just the body, if none was found.
let descendant = match kind {
- FigureKind::Elem(func) => elem
- .body()
- .query_first(&Selector::Elem(func, None))
- .map(Cow::Owned),
+ FigureKind::Elem(func) => {
+ elem.body.query_first(&Selector::Elem(func, None)).map(Cow::Owned)
+ }
FigureKind::Name(_) => None,
};
- let target = descendant.unwrap_or_else(|| Cow::Borrowed(elem.body()));
+ let target = descendant.unwrap_or_else(|| Cow::Borrowed(&elem.body));
Some(supplement.resolve(engine, styles, [target])?)
}
};
@@ -437,7 +436,7 @@ impl Outlinable for Packed<FigureElem> {
return Ok(None);
};
- let mut realized = caption.body().clone();
+ let mut realized = caption.body.clone();
if let (
Smart::Custom(Some(Supplement::Content(mut supplement))),
Some(Some(counter)),
@@ -460,7 +459,7 @@ impl Outlinable for Packed<FigureElem> {
let separator = caption.get_separator(StyleChain::default());
- realized = supplement + numbers + separator + caption.body();
+ realized = supplement + numbers + separator + caption.body.clone();
}
Ok(Some(realized))
@@ -604,7 +603,7 @@ impl Synthesize for Packed<FigureCaption> {
impl Show for Packed<FigureCaption> {
#[typst_macros::time(name = "figure.caption", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- let mut realized = self.body().clone();
+ let mut realized = self.body.clone();
if let (
Some(Some(mut supplement)),
diff --git a/crates/typst-library/src/model/footnote.rs b/crates/typst-library/src/model/footnote.rs
index ffc78ea0..f3b2a19e 100644
--- a/crates/typst-library/src/model/footnote.rs
+++ b/crates/typst-library/src/model/footnote.rs
@@ -105,12 +105,12 @@ impl FootnoteElem {
/// Tests if this footnote is a reference to another footnote.
pub fn is_ref(&self) -> bool {
- matches!(self.body(), FootnoteBody::Reference(_))
+ matches!(self.body, FootnoteBody::Reference(_))
}
/// Returns the content of the body of this footnote if it is not a ref.
pub fn body_content(&self) -> Option<&Content> {
- match self.body() {
+ match &self.body {
FootnoteBody::Content(content) => Some(content),
_ => None,
}
@@ -120,9 +120,9 @@ impl FootnoteElem {
impl Packed<FootnoteElem> {
/// Returns the location of the definition of this footnote.
pub fn declaration_location(&self, engine: &Engine) -> StrResult<Location> {
- match self.body() {
+ match self.body {
FootnoteBody::Reference(label) => {
- let element = engine.introspector.query_label(*label)?;
+ let element = engine.introspector.query_label(label)?;
let footnote = element
.to_packed::<FootnoteElem>()
.ok_or("referenced element should be a footnote")?;
@@ -281,12 +281,11 @@ impl Show for Packed<FootnoteEntry> {
#[typst_macros::time(name = "footnote.entry", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
let span = self.span();
- let note = self.note();
let number_gap = Em::new(0.05);
let default = StyleChain::default();
- let numbering = note.numbering(default);
+ let numbering = self.note.numbering(default);
let counter = Counter::of(FootnoteElem::elem());
- let Some(loc) = note.location() else {
+ let Some(loc) = self.note.location() else {
bail!(
span, "footnote entry must have a location";
hint: "try using a query or a show rule to customize the footnote instead"
@@ -304,7 +303,7 @@ impl Show for Packed<FootnoteEntry> {
HElem::new(self.indent(styles).into()).pack(),
sup,
HElem::new(number_gap.into()).with_weak(true).pack(),
- note.body_content().unwrap().clone(),
+ self.note.body_content().unwrap().clone(),
]))
}
}
diff --git a/crates/typst-library/src/model/heading.rs b/crates/typst-library/src/model/heading.rs
index ec9cf4e9..db131afe 100644
--- a/crates/typst-library/src/model/heading.rs
+++ b/crates/typst-library/src/model/heading.rs
@@ -223,7 +223,7 @@ impl Show for Packed<HeadingElem> {
const SPACING_TO_NUMBERING: Em = Em::new(0.3);
let span = self.span();
- let mut realized = self.body().clone();
+ let mut realized = self.body.clone();
let hanging_indent = self.hanging_indent(styles);
let mut indent = match hanging_indent {
@@ -360,7 +360,7 @@ impl Outlinable for Packed<HeadingElem> {
return Ok(None);
}
- let mut content = self.body().clone();
+ let mut content = self.body.clone();
if let Some(numbering) = (**self).numbering(StyleChain::default()).as_ref() {
let numbers = Counter::of(HeadingElem::elem()).display_at_loc(
engine,
diff --git a/crates/typst-library/src/model/link.rs b/crates/typst-library/src/model/link.rs
index bbc47da0..4558cb39 100644
--- a/crates/typst-library/src/model/link.rs
+++ b/crates/typst-library/src/model/link.rs
@@ -102,11 +102,10 @@ impl LinkElem {
impl Show for Packed<LinkElem> {
#[typst_macros::time(name = "link", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- let body = self.body().clone();
- let dest = self.dest();
+ let body = self.body.clone();
Ok(if TargetElem::target_in(styles).is_html() {
- if let LinkTarget::Dest(Destination::Url(url)) = dest {
+ if let LinkTarget::Dest(Destination::Url(url)) = &self.dest {
HtmlElem::new(tag::a)
.with_attr(attr::href, url.clone().into_inner())
.with_body(Some(body))
@@ -120,7 +119,7 @@ impl Show for Packed<LinkElem> {
body
}
} else {
- let linked = match self.dest() {
+ let linked = match &self.dest {
LinkTarget::Dest(dest) => body.linked(dest.clone()),
LinkTarget::Label(label) => {
let elem = engine.introspector.query_label(*label).at(self.span())?;
diff --git a/crates/typst-library/src/model/outline.rs b/crates/typst-library/src/model/outline.rs
index e8d32a54..84661c1c 100644
--- a/crates/typst-library/src/model/outline.rs
+++ b/crates/typst-library/src/model/outline.rs
@@ -219,8 +219,7 @@ impl Show for Packed<OutlineElem> {
continue;
};
- let level = entry.level();
- if depth < *level {
+ if depth < entry.level {
continue;
}
@@ -229,7 +228,7 @@ impl Show for Packed<OutlineElem> {
while ancestors
.last()
.and_then(|ancestor| ancestor.with::<dyn Outlinable>())
- .is_some_and(|last| last.level() >= *level)
+ .is_some_and(|last| last.level() >= entry.level)
{
ancestors.pop();
}
@@ -483,7 +482,7 @@ impl Show for Packed<OutlineEntry> {
#[typst_macros::time(name = "outline.entry", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
let mut seq = vec![];
- let elem = self.element();
+ let elem = &self.element;
// In case a user constructs an outline entry with an arbitrary element.
let Some(location) = elem.location() else {
@@ -512,7 +511,7 @@ impl Show for Packed<OutlineEntry> {
seq.push(TextElem::packed("\u{202B}"));
}
- seq.push(self.body().clone().linked(Destination::Location(location)));
+ seq.push(self.body.clone().linked(Destination::Location(location)));
if rtl {
// "Pop Directional Formatting"
@@ -520,7 +519,7 @@ impl Show for Packed<OutlineEntry> {
}
// Add filler symbols between the section name and page number.
- if let Some(filler) = self.fill() {
+ if let Some(filler) = &self.fill {
seq.push(SpaceElem::shared().clone());
seq.push(
BoxElem::new()
@@ -535,7 +534,7 @@ impl Show for Packed<OutlineEntry> {
}
// Add the page number.
- let page = self.page().clone().linked(Destination::Location(location));
+ let page = self.page.clone().linked(Destination::Location(location));
seq.push(page);
Ok(Content::sequence(seq))
diff --git a/crates/typst-library/src/model/quote.rs b/crates/typst-library/src/model/quote.rs
index 110825f1..2eaa32d4 100644
--- a/crates/typst-library/src/model/quote.rs
+++ b/crates/typst-library/src/model/quote.rs
@@ -156,7 +156,7 @@ cast! {
impl Show for Packed<QuoteElem> {
#[typst_macros::time(name = "quote", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- let mut realized = self.body().clone();
+ let mut realized = self.body.clone();
let block = self.block(styles);
if self.quotes(styles) == Smart::Custom(true) || !block {
diff --git a/crates/typst-library/src/model/reference.rs b/crates/typst-library/src/model/reference.rs
index 96aa2117..31661768 100644
--- a/crates/typst-library/src/model/reference.rs
+++ b/crates/typst-library/src/model/reference.rs
@@ -182,9 +182,8 @@ impl Synthesize for Packed<RefElem> {
elem.push_citation(Some(citation));
elem.push_element(None);
- let target = *elem.target();
- if !BibliographyElem::has(engine, target) {
- if let Ok(found) = engine.introspector.query_label(target).cloned() {
+ if !BibliographyElem::has(engine, elem.target) {
+ if let Ok(found) = engine.introspector.query_label(elem.target).cloned() {
elem.push_element(Some(found));
return Ok(());
}
@@ -197,8 +196,7 @@ impl Synthesize for Packed<RefElem> {
impl Show for Packed<RefElem> {
#[typst_macros::time(name = "ref", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- let target = *self.target();
- let elem = engine.introspector.query_label(target);
+ let elem = engine.introspector.query_label(self.target);
let span = self.span();
let form = self.form(styles);
@@ -229,7 +227,7 @@ impl Show for Packed<RefElem> {
}
// RefForm::Normal
- if BibliographyElem::has(engine, target) {
+ if BibliographyElem::has(engine, self.target) {
if elem.is_ok() {
bail!(span, "label occurs in the document and its bibliography");
}
@@ -240,7 +238,7 @@ impl Show for Packed<RefElem> {
let elem = elem.at(span)?;
if let Some(footnote) = elem.to_packed::<FootnoteElem>() {
- return Ok(footnote.into_ref(target).pack().spanned(span));
+ return Ok(footnote.into_ref(self.target).pack().spanned(span));
}
let elem = elem.clone();
@@ -319,7 +317,7 @@ fn to_citation(
engine: &mut Engine,
styles: StyleChain,
) -> SourceResult<Packed<CiteElem>> {
- let mut elem = Packed::new(CiteElem::new(*reference.target()).with_supplement(
+ let mut elem = Packed::new(CiteElem::new(reference.target).with_supplement(
match reference.supplement(styles).clone() {
Smart::Custom(Some(Supplement::Content(content))) => Some(content),
_ => None,
diff --git a/crates/typst-library/src/model/table.rs b/crates/typst-library/src/model/table.rs
index 7dfaf45d..fa44cb58 100644
--- a/crates/typst-library/src/model/table.rs
+++ b/crates/typst-library/src/model/table.rs
@@ -706,7 +706,7 @@ cast! {
impl Show for Packed<TableCell> {
fn show(&self, _engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- show_grid_cell(self.body().clone(), self.inset(styles), self.align(styles))
+ show_grid_cell(self.body.clone(), self.inset(styles), self.align(styles))
}
}
diff --git a/crates/typst-library/src/model/terms.rs b/crates/typst-library/src/model/terms.rs
index 13aa8c6d..1261ea4f 100644
--- a/crates/typst-library/src/model/terms.rs
+++ b/crates/typst-library/src/model/terms.rs
@@ -151,12 +151,12 @@ impl Show for Packed<TermsElem> {
.then(|| HElem::new((-hanging_indent).into()).pack().spanned(span));
let mut children = vec![];
- for child in self.children().iter() {
+ for child in self.children.iter() {
let mut seq = vec![];
seq.extend(unpad.clone());
- seq.push(child.term().clone().strong());
+ seq.push(child.term.clone().strong());
seq.push((*separator).clone());
- seq.push(child.description().clone());
+ seq.push(child.description.clone());
children.push(StackChild::Block(Content::sequence(seq)));
}
diff --git a/crates/typst-library/src/text/deco.rs b/crates/typst-library/src/text/deco.rs
index 5da7ecec..485d0edc 100644
--- a/crates/typst-library/src/text/deco.rs
+++ b/crates/typst-library/src/text/deco.rs
@@ -81,7 +81,7 @@ pub struct UnderlineElem {
impl Show for Packed<UnderlineElem> {
#[typst_macros::time(name = "underline", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration {
+ Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration {
line: DecoLine::Underline {
stroke: self.stroke(styles).unwrap_or_default(),
offset: self.offset(styles),
@@ -173,7 +173,7 @@ pub struct OverlineElem {
impl Show for Packed<OverlineElem> {
#[typst_macros::time(name = "overline", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration {
+ Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration {
line: DecoLine::Overline {
stroke: self.stroke(styles).unwrap_or_default(),
offset: self.offset(styles),
@@ -250,7 +250,7 @@ pub struct StrikeElem {
impl Show for Packed<StrikeElem> {
#[typst_macros::time(name = "strike", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration {
+ Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration {
// Note that we do not support evade option for strikethrough.
line: DecoLine::Strikethrough {
stroke: self.stroke(styles).unwrap_or_default(),
@@ -345,7 +345,7 @@ pub struct HighlightElem {
impl Show for Packed<HighlightElem> {
#[typst_macros::time(name = "highlight", span = self.span())]
fn show(&self, _: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().styled(TextElem::set_deco(smallvec![Decoration {
+ Ok(self.body.clone().styled(TextElem::set_deco(smallvec![Decoration {
line: DecoLine::Highlight {
fill: self.fill(styles),
stroke: self
diff --git a/crates/typst-library/src/text/mod.rs b/crates/typst-library/src/text/mod.rs
index d372c399..6cca2458 100644
--- a/crates/typst-library/src/text/mod.rs
+++ b/crates/typst-library/src/text/mod.rs
@@ -794,7 +794,7 @@ impl Construct for TextElem {
impl PlainText for Packed<TextElem> {
fn plain_text(&self, text: &mut EcoString) {
- text.push_str(self.text());
+ text.push_str(&self.text);
}
}
diff --git a/crates/typst-library/src/text/raw.rs b/crates/typst-library/src/text/raw.rs
index cd718d2a..01d6d8f0 100644
--- a/crates/typst-library/src/text/raw.rs
+++ b/crates/typst-library/src/text/raw.rs
@@ -315,7 +315,7 @@ impl Packed<RawElem> {
#[comemo::memoize]
fn highlight(&self, styles: StyleChain) -> Vec<Packed<RawLine>> {
let elem = self.as_ref();
- let lines = preprocess(elem.text(), styles, self.span());
+ let lines = preprocess(&elem.text, styles, self.span());
let count = lines.len() as i64;
let lang = elem
@@ -490,7 +490,7 @@ impl Figurable for Packed<RawElem> {}
impl PlainText for Packed<RawElem> {
fn plain_text(&self, text: &mut EcoString) {
- text.push_str(&self.text().get());
+ text.push_str(&self.text.get());
}
}
@@ -638,13 +638,13 @@ pub struct RawLine {
impl Show for Packed<RawLine> {
#[typst_macros::time(name = "raw.line", span = self.span())]
fn show(&self, _: &mut Engine, _styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone())
+ Ok(self.body.clone())
}
}
impl PlainText for Packed<RawLine> {
fn plain_text(&self, text: &mut EcoString) {
- text.push_str(self.text());
+ text.push_str(&self.text);
}
}
diff --git a/crates/typst-library/src/text/shift.rs b/crates/typst-library/src/text/shift.rs
index 9723bbf0..3eec0758 100644
--- a/crates/typst-library/src/text/shift.rs
+++ b/crates/typst-library/src/text/shift.rs
@@ -50,7 +50,7 @@ pub struct SubElem {
impl Show for Packed<SubElem> {
#[typst_macros::time(name = "sub", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- let body = self.body().clone();
+ let body = self.body.clone();
if self.typographic(styles) {
if let Some(text) = convert_script(&body, true) {
@@ -109,7 +109,7 @@ pub struct SuperElem {
impl Show for Packed<SuperElem> {
#[typst_macros::time(name = "super", span = self.span())]
fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
- let body = self.body().clone();
+ let body = self.body.clone();
if self.typographic(styles) {
if let Some(text) = convert_script(&body, false) {
@@ -132,9 +132,9 @@ fn convert_script(content: &Content, sub: bool) -> Option<EcoString> {
Some(' '.into())
} else if let Some(elem) = content.to_packed::<TextElem>() {
if sub {
- elem.text().chars().map(to_subscript_codepoint).collect()
+ elem.text.chars().map(to_subscript_codepoint).collect()
} else {
- elem.text().chars().map(to_superscript_codepoint).collect()
+ elem.text.chars().map(to_superscript_codepoint).collect()
}
} else if let Some(sequence) = content.to_packed::<SequenceElem>() {
sequence
diff --git a/crates/typst-library/src/text/smallcaps.rs b/crates/typst-library/src/text/smallcaps.rs
index bf003bd1..1e88974f 100644
--- a/crates/typst-library/src/text/smallcaps.rs
+++ b/crates/typst-library/src/text/smallcaps.rs
@@ -53,6 +53,6 @@ pub struct SmallcapsElem {
impl Show for Packed<SmallcapsElem> {
#[typst_macros::time(name = "smallcaps", span = self.span())]
fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult<Content> {
- Ok(self.body().clone().styled(TextElem::set_smallcaps(true)))
+ Ok(self.body.clone().styled(TextElem::set_smallcaps(true)))
}
}